If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > US/GB Dates in ASP/ACCESS

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-19-04, 10:15
mindless mindless is offline
Registered User
 
Join Date: Sep 2003
Location: Shrewsbury, England
Posts: 4
US/GB Dates in ASP/ACCESS

I'm having real trouble in processing Dates entered on an asp form to be stored in an Access database.

I want to use the English date format of dd/mm/yyyy but the dates keep getting converted to american mm/dd/yyyy, i've tried everything I can think of.

The only way i've been able to continue to develop my site is to use a text field for dates as a temporary measure however i'm unable to search for dates or between dates using this method.

This has been buggin me for ages so anyone out there who can shed some light on it I would be really gratefull.


Shaun
Reply With Quote
  #2 (permalink)  
Old 03-20-04, 15:42
MrWizard MrWizard is offline
Registered User
 
Join Date: Mar 2003
Location: Atlanta, GA
Posts: 191
Re: US/GB Dates in ASP/ACCESS

This is a sticky issue with no easy answer.

Using a string format, and coverting to the proper format is one way to do it, and many people do it that way.

I use locale ID's. There are some drawbacks with this as well.

At the top of my code, I do the following....

xLCID=GetLocale '## Do Not Edit
Session.LCID=xLCID


Then, when doing anything that WRITES data to the database, I do...

Session.LCID=1033
'f3 is a DATE field
SQLx="INSERT INTO table (f1,f2,f3) VALUES (" & v1 & "," & v2 & ",#" & Date() & "#)"
Session.LCID=xLCID
'dbexecute is my routine that handles all the db calls
dbexecuteX(SQLx)

Basically this code reads the currently installed localeID (language and format identifier) that the server is set to, and stores it so we know how the user prefers to SEE the data.

Then, prior to saving any DATE data, we set the locale ID for the session to US-English Format... so that ALL dates are STORED in the same format. It's important that this is done when creating the SQL statement itself.

Once the SQL is formed, then we switch the locale ID back to how the user prefers it.

Finally, we execute the SQL to update the data.

This has worked well for me. There are SO MANY issues when dealing with dates.... you must be very careful if you plan to handle internationally aware applications.

Tim
__________________
Tim
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On