Print Page | Close Window

Datetime and SQL Server

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=15283
Printed Date: 30 March 2026 at 5:05am
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Datetime and SQL Server
Posted By: ub3rl337ch3ch
Subject: Datetime and SQL Server
Date Posted: 29 May 2005 at 10:38pm
I know this question has been asked zillions of times, but the answers other people get never seem to quite work for me. I have a datetime field in an sql server, which needs to have data entered to it. 
 
I need format through the entire process of submitting, validating and writing to th db to use dd/mm/yyyy, and i am using Session.LCID = 3081 for australian settings, being as how i'm in australia.
 
If i enter a date in dd/mm/yyyy format where dd is > 12, it spits an error at me
 
(The conversion of char data type to smalldatetime data type resulted in an out-of-range smalldatetime value.)
 
When i try mm/dd/yyyy it posts fine, but when the date is called from the database, it displays as dd/mm/yyyy.
 
In fact, when i submit any date (as long as it is in mm/dd/yyyy) it gets recorded to the database as dd/mm/yyyy, so 03/04/2005 ends up as 04/03/2005 and vv.
 
Does anyone know what is causing this and how i can fix it?
 
UPDATE: even when not using session.LCID, it still switches from mm/dd/yyyy to dd/mm/yyyy on posting



Replies:
Posted By: ub3rl337ch3ch
Date Posted: 30 May 2005 at 8:47pm

FIX:

i fiured since it was swapping everything around when i inserted it, i'd swap it around before inserting so it would swap back to what it should be. I used this:
 
function formatdate(thedate)
theday = datepart("d",thedate)
themonth = datepart("m",thedate)
theyear = datepart("yyyy",thedate)
thedate = themonth & "/" & theday & "/" & theyear
end function



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