R
rn5a
I have 2 variables - 'dt1' & 'dt2' - of type DateTime. Assume that one
of the values of 'dt1' (which is being retrieved from a DB table) is
27/12/2006 6:54:27 AM & the value of 'dt2' is the current date & time,
say, 30/12/2006 3:09:22 PM.
I have the following code which uses the built-in DateDiff function:
Dim dt1 As DateTime
Dim dt2 As DateTime
dt2 = DateTime.Now
If (DateDiff(DateInterval.Day, CDate(dt1), CDate(dt2)) < 3) Then
Label1.Text = "Less than 3 days have elapsed"
Else
Label1.Text = "3 or more than 3 days have elapsed"
End If
The DateDiff function above evaluates to 3 & since 3 < 3 evaluates to
False; the Else condition must get satisfied but when the value of
'dt1' is 27/12/2006 6:54:27 AM, then the If condition gets satisfied!
Why so?
of the values of 'dt1' (which is being retrieved from a DB table) is
27/12/2006 6:54:27 AM & the value of 'dt2' is the current date & time,
say, 30/12/2006 3:09:22 PM.
I have the following code which uses the built-in DateDiff function:
Dim dt1 As DateTime
Dim dt2 As DateTime
dt2 = DateTime.Now
If (DateDiff(DateInterval.Day, CDate(dt1), CDate(dt2)) < 3) Then
Label1.Text = "Less than 3 days have elapsed"
Else
Label1.Text = "3 or more than 3 days have elapsed"
End If
The DateDiff function above evaluates to 3 & since 3 < 3 evaluates to
False; the Else condition must get satisfied but when the value of
'dt1' is 27/12/2006 6:54:27 AM, then the If condition gets satisfied!
Why so?