Home  |  About  |   Search   

What's New
Table Of Contents
Credits
Netiquette
10 Commandments 
Bugs
Tables
Queries
Forms
Reports
Modules
APIs
Strings
Date/Time
General
Downloads
Resources
Search
Feedback
mvps.org

RunCommand Constants

Terms of Use


 

Date/Time: Return Dates in US #mm/dd/yyyy# format

Author(s)
Joe Foster
(Q)    I'm having problems dealing with dates in my queries/SQL code. My regional settings are in the format #dd/mm/yyyy# and it doesn't work in Access.

(A)    VBA assumes automatically that any dates being used follow US Settings, ie #mm/dd/yyyy#. Use the Format function to return the correct date.
'Code Courtesy of
'Joe Foster
'
Global Const JetDateTimeFmt = "\#mm\/dd\/yyyy hh\:nn\:ss\#;;;\N\u\l\l"
Global Const JetDateFmt = "\#mm\/dd\/yyyy\#;;;\N\u\l\l"
Global Const JetTimeFmt = "\#hh\:nn\:ss\#;;;\N\u\l\l"

and then

SQL = SQL & "When >= " & Format$(Now, JetDateTimeFmt)


1998-2009, Dev Ashish & Arvin Meyer, All rights reserved. Optimized for Microsoft Internet Explorer