Thursday, April 24, 2008

Formatting a Date in Microsoft Access

More for my future reference, than your edification:

For some unknown reason, I had a reasonably difficult time formatting a date within Microsoft Access. The format of the date was to be in YYYY-MM-DD format, and while searching for assistance, I stumbled upon this solution:

Format([DATE], 'yyyy-mm-dd')

This worked when querying against a table, but if you wanted to use this in a query of a query, then I started receiving this message:

Syntax error (comma) in query expression

In typical Microsoft fashion, this really meant nothing to me. After hacking around, I finally found that I had to write the formula like this to work:

Format([TABLENAME.DATE], 'yyyy-mm-dd')

No comments: