How to specify date format in visual basic 6?

Status
Not open for further replies.

Shayon

Broken In
Well, I've been trying to compare dates using the CDate() function. For example, I wish to compare 5th of June, 2007 and 2nd of July, 2008. Now, everytime I try comparing these dates as :

Code:
 MsgBox CDate("05/06/2007") >= CDate("02/07/2007")
The answer I get is True because it treats them as 05062007 and 02072007 (at least, that's wot it seems) and ofcourse, 05062007 is larger.

I feel it'd help me if, right when a form loads, I could specify my default date format as yyyy/mm/dd. Could you please let me know how to do that effectively?

Or, it'd even help a lot if you could tell me how to compare dates, more efficiently!!
 

RCuber

The Mighty Unkel!!!
Staff member
try this
Code:
Dim i As Integer
i = DateDiff("d", "05/06/2007", "02/07/2007")
If i < 0 Then
MsgBox "FLASE"
Else
MsgBox "TRUE"
End If
 
Status
Not open for further replies.
Top Bottom