Comparing Date-typed Variables

Comparing Date-typed Variables

How do I compare dates in VB? Also, how do I store dates into Access? I can’tget them into the right format.

For comparison of dates, look up the documentation on the DateDiff function. There are several other similar functions for adding dates and getting pieces of the date. DateDiff is a very powerful and useful function.

As far as storing dates, Access is fairly forgiving about how dates look. If you are doing insert statements into the database, put the date into a Variant type before you do it as Access likes that better. You can use the CVar function to convert just about anything to a variant, but don’t use Variant variables as each one takes 64k of memory. Not good. If you set the format property on the masked edit box, you can get the date in the format you want fairly easily.

To format dates, use the Format function. The Format function allows you to format a date in virtually any format imaginable, including generic International dates.

See also  Monetize TikTok For Your Business

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