Results 1 to 2 of 2
  1. #1
    Join Date
    Sep 2003
    Location
    Shrewsbury, England
    Posts
    4

    Unanswered: 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

  2. #2
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •