Please Help- Can't get date functions to work correctly 
Author Message
 Please Help- Can't get date functions to work correctly

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



Mon, 25 Jun 2001 03:00:00 GMT  
 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



Tue, 26 Jun 2001 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. MaskedEdit, Problem getting it to work correctly with database date field

2. BUG: VB4(16 bit) - Int and Fix functions don't work correctly

3. int function doesn't work correctly.

4. DestroyWindow function doesn't work correctly

5. Please, Please, Please I need help working with dates

6. Help Please-hyperlink in VB from Access won't show correctly

7. Please help: ShellExecute won't launch Word Viewer correctly

8. Date, Trim, STR Functions Don't Work

9. Please help me getting help to work

10. Getting Microsoft's Win32API Declarations to Compile Correctly

11. 'Canned' data in VB program

12. TransferText method in function does not working correctly

 

 
Powered by phpBB® Forum Software