Print Page | Close Window

date changes in database

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=16727
Printed Date: 29 March 2026 at 5:07pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: date changes in database
Posted By: JOS121212
Subject: date changes in database
Date Posted: 28 September 2005 at 3:26pm
hi people

I have a website (ASP) with a secure area where users can enter information and maintain it. One page deals with new (music) releases. When I enter a date it needs to be in the format dd-mm-yyyy. In the global.asa I have entered the session.lcid=1043.
BUT: every time I enter a date in the form, like 1-9-2005, after processing the database returns 9-1-2005. I have done some tests like response.write date before entering it into the database and then the result is okay. So the reversal occurs at the moment that the date is entered into the database. However, somehow 9-1-2005 gets entered into the database.
I don't get it. And the strangest part is that when I enter a date that cannot be reversed, like 15-9-2005 the result is okay.....

Who can solve this one?



Replies:
Posted By: michael
Date Posted: 28 September 2005 at 6:44pm
Use setdateformat in sql server if you cannot change the global properties of SQL
 
SET DATEFORMAT dmy
GO
DECLARE @datevar datetime
SET @datevar = '1/9/05'
SELECT @datevar
GO
you can use I think dmy, mdy ymd and so on to specify what order the inputstring is....


-------------
http://baumannphoto.com" rel="nofollow - Blog | http://mpgtracker.com" rel="nofollow - MPG Tracker


Posted By: JOS121212
Date Posted: 29 September 2005 at 12:22am
Thanks Michael,
but as I said in my post, the site is an ASP site. So I don't work with php and sql but with asp and access....


Posted By: michael
Date Posted: 29 September 2005 at 8:09am
Oh did not see the access part. Not sure how you set that in access

-------------
http://baumannphoto.com" rel="nofollow - Blog | http://mpgtracker.com" rel="nofollow - MPG Tracker


Posted By: JOS121212
Date Posted: 29 September 2005 at 3:10pm
okay, and thanks for your effort!


Posted By: tskaar
Date Posted: 03 October 2005 at 8:00am
It should work if you use the following code in Global ASA




 Sub Session_OnStart

     Session.LCID = 1043

End Sub



If not, try to put

    <% Session.LCID = 1043 %>   


in top of your ASP-pages


Posted By: ub3rl337ch3ch
Date Posted: 31 October 2005 at 6:06pm
you might want to check the format of the date field within access, check that it does not have a format mask, or whatever it's called. Also, check whether the change in the date happens when the date gets to access, or after it gets recalled from the database...
 
if all else fails, try running the following function on your dates before you insert them... i had an access backend for a page i was working on months ago that i had this problem with, and it fixed it...
 
 
function formatdate(thedate)
theday = datepart("d",thedate)
themonth = datepart("m",thedate)
theyear = datepart("yyyy",thedate)
thedate = themonth & "/" & theday & "/" & theyear
end function
 
don't ask me why it does it... i knew, i forgot, we moved on with our lives... LOL



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net