
Please Help- Can't get date functions to work correctly
Two points. Firstly, the Jet Database Engine ONLY recognises date constants in
the US format (ie: #mm/dd/yy#") When including your date in a SQL Statement,
either use that format, or alternatively you can use the "DateValue" function,
which is aware of international settings eg: "WHERE Field =
DateValue('30/12/98')" will work with European settings.
2nd, the "Format " statement is able to recognise the International date
settings as defined in the Windows setup. Use Format(DateVariable, "Short Date")
or Format(DateVariable, "Long Date"), and the date will be formatted correctly
according to the International settings.
Hope this helps.
Mick
Quote:
> I have a question for those who have dealt with writeing programs for use
> worldwide.
> I wrote a VB3 program using Access 2 for the database. My question regards
> dates with respect to international users (I am in the US). I have already
> modified my program to eliminate regional specific dates (e.g.
> Format$(myVar, "mm/dd/yy") was replaced with either DateValue("myDate") or
> DateSerial(yy,mm,dd)). The problem is that I have some queries to my
> database (e.g. SELECT DateDiff('yyyy',myDate1,myDate2) FROM myTable) where
> I can't see another way to run the query. I know, for example, that in South
> America the Regional Settings applet for Dates has "dd-mm-aaaa" instead of
> "dd-mm-yyyy" as in the States. If I run code as shown above in South
> America, will the program crash because it doesn't understand what "yyyy" is
> or is all that internal to VB and it will select the appropriate "aaaa"?
> Furthermore, is there an easy way to determine the Year of an entered date
> and keep it in the same format as it was entered (i.e. if I enter 98/1/1, I
> want the program to extract the 98 but not to add the prefix to it [if I use
> Year(myVar) it will come back as 1998])? I need this for my Y2K functions.
> Thanks for any help...
> Ronald Levy, M.D.
> Assistant Professor of Anesthesiology
> UTMB-Galveston