devxlogo

Don’t use = operator on Date values

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) 

devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist