• CONTEST ALERT - Experience the power of DDR5 memory with Kingston Click for details

How to specify date format in visual basic 6?

Not open for further replies.


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 :

 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!!


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