View Full Version : access and dates

06-04-2007, 09:38 PM

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!

06-04-2007, 10:07 PM
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().

2day = datepart("d",date()) & "/" & datepart("m",date()) & "/" & datepart("yyyy", date())
response.write 2day

The above code would return 4/6/2007.


06-04-2007, 10:29 PM
i set the lcid like this:


06-04-2007, 10:36 PM
Yep, that's Great Britain.

Once you set that, do a


and see what they return.

OR try the datepart that I did above.


06-05-2007, 08:27 AM
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!

06-05-2007, 02:29 PM
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.

06-05-2007, 11:32 PM
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?