Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    Regular Coder
    Join Date
    Jul 2005
    Location
    Oxfordshire, UK
    Posts
    144
    Thanks
    0
    Thanked 0 Times in 0 Posts

    access and dates

    Hi,

    I have this code that puts the current date into a text box, its in the format of dd/mm/yyyy. what happens next is it queries that db usinf this date and should return the id for that date, however whats happening is the db is returning the id for the date mm/dd/yyyy.

    For example. today is 4/6/2007 it shows this in the text box by using date() and it querys the database but returns the id for 6/4/2007

    the dates are stored in the database in format dd/mm/yyyy

    any ideas where this is going wrong?

    i have tried putting lcid at the top of the page and that doesnt work, i have also tried put # round my date in the sql query but that didnt seem to work...

    Hope someone can help, its been driving me mad today!

  • #2
    Regular Coder
    Join Date
    Mar 2007
    Posts
    505
    Thanks
    1
    Thanked 19 Times in 19 Posts
    When you put LCID on the top of your page, did you set it to en-gb (or Great Britain)?

    If you did and you are still getting the wrong date, try doing datepart().

    Code:
    2day = datepart("d",date()) & "/" & datepart("m",date()) & "/" & datepart("yyyy", date())
    response.write 2day
    The above code would return 4/6/2007.

    HTH!
    To say my fate is not tied to your fate is like saying, 'Your end of the boat is sinking.' -- Hugh Downs
    Please, if you found my post helpful, pay it forward. Go and help someone else today.

  • #3
    Regular Coder
    Join Date
    Jul 2005
    Location
    Oxfordshire, UK
    Posts
    144
    Thanks
    0
    Thanked 0 Times in 0 Posts
    i set the lcid like this:
    Code:
    <%Session.LCID=2057%>

  • #4
    Regular Coder
    Join Date
    Mar 2007
    Posts
    505
    Thanks
    1
    Thanked 19 Times in 19 Posts
    Yep, that's Great Britain.

    Once you set that, do a

    response.write(date())
    response.write(formatdatetime(date(),2)

    and see what they return.

    OR try the datepart that I did above.

    HTH!
    To say my fate is not tied to your fate is like saying, 'Your end of the boat is sinking.' -- Hugh Downs
    Please, if you found my post helpful, pay it forward. Go and help someone else today.

  • #5
    Regular Coder
    Join Date
    Jul 2005
    Location
    Oxfordshire, UK
    Posts
    144
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question

    sorry, maybe i didnt explain it to clear in my first post.

    i have all the dates in my db for the next 10 years or what ever and what i do is query that table with todays date using date() and it should return me the id number for that date : the dates are in the table in format dd/mm/yyyy.

    i response.write (date()) into the text field in a form and it displays the correct date dd/mm/yyyy and thats all fine, however, when i run the query to get the id for todays date it returns the id number for mm/dd/yyyy...

    It doesnt seem to be an issue with writing the date, it appears that it gets swapped round when its put into the access db...

    i have checked all the regional settings on the server etc and everything i can think of is set to UK. I have used this code on another server and it works fine so im thinking its something unique to the server and not the code. the server is win 2k3 iis6.

    Hope someone can help with this cos its driving me insane now!

  • #6
    Regular Coder
    Join Date
    Mar 2007
    Posts
    505
    Thanks
    1
    Thanked 19 Times in 19 Posts
    Silly question -- When you set the Regional Settings on the server, did you reboot? Rebooting fixes 90% of all Windows problems, esp. if the Access LDB file was still in memory or being used and the MDB hasn't been closed and re-opened.

    Access should be using the Regional Settings of the localhost to define it's Date, Time, and Currency settings.

    You might also want to check the global.asa file to see if the date formats are being changed there.

    That's about all that I can offer you. I haven't used Access in 5+ years, so I am not that familiar with it any more.
    To say my fate is not tied to your fate is like saying, 'Your end of the boat is sinking.' -- Hugh Downs
    Please, if you found my post helpful, pay it forward. Go and help someone else today.

  • #7
    Regular Coder westmatrix99's Avatar
    Join Date
    Dec 2006
    Location
    South Africa
    Posts
    307
    Thanks
    12
    Thanked 0 Times in 0 Posts
    Access does have that issues with lock files; .LDB
    Hate it, but can be overlooked.
    Regional Settings are a problem but once you set it then it's your code that is the issue.

    Is it working now?
    Thanks for you support!


  •  

    Posting Permissions

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