Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: VB5,VB6
Expertise: Intermediate
May 13, 2000

Don't use = operator on Date values

Date variables store values in floating point format, much like Double variables, with the integer part for dates and the fractional part for the time portion. Being floating point values, Data values may be subject to rounding problems, and for this reason you shouldn't test two Date variables for equality using the "=" operator.

Instead, use the DateDiff function, or evaluate the difference between the two values and check that it's less than a very small value, as in:


If Abs(Date1 - Date2) < 1E-10 Then
    MsgBox "Same dates"
End If
Francesco Balena
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date