devxlogo

Changing Date Format

Changing Date Format

Question:
I am having trouble saving dates into an Access 1.1 DateTime field. The aplication I am writing is for the European market, so international dates are a problem as well.I am putting the current date into a Truegrid table as a string. When I try to convertit into a date I get Type Mismatch error. I get the same error if I try and save itto the database. Any advice would be most welcome. Thank you.

Answer:
Try this for converting string to date:

DateField = CVar(String)
For converting from date to string, try using the Format$ function like this:
String = Format$(DateField, “MM-DD-YY”)
Also be aware that your problems might lie with the codepage that your keyboard is set to. If you’re using a “US English” codepage and are trying to translate to a different (i.e. European) format it might be causing the type mismatch.

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