Click to See Complete Forum and Search --> : problem with comapring dates


rahulvasanth
April 27th, 2006, 03:37 AM
I have two date values

04/26/2006 11:25:20 AM and 04/26/2006 11:20:22 AM

I want to compare the two dates. If the first date is greater than the second date, then I have to display a message.

I m trying the following code :

IF cdate(04/26/2006 11:25:20 AM) > cdate(04/26/2006 11:20:22 AM) then

display message

END IF

But the condition returns FALSE and the message is not displayed.

Can anyone guide me where I m going wrong.

Thanking in advance

Shuja Ali
April 27th, 2006, 03:54 AM
Have you tried Date.Compare method. Here is a simple illustration If (Date.Compare(Convert.ToDateTime("04/26/2006 11:25:20 AM"), Convert.ToDateTime("04/26/2006 11:20:20 AM"))) > 0 Then
'dt1 is greater than dt2
Else
'dt1 is less that dt2
End If

rahulvasanth
April 27th, 2006, 05:45 AM
Its working

Thanks