Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Datetime and SQL Server
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Datetime and SQL Server

 Post Reply Post Reply
Author
ub3rl337ch3ch View Drop Down
Senior Member
Senior Member
Avatar

Joined: 16 February 2005
Location: Australia
Status: Offline
Points: 341
Post Options Post Options   Thanks (0) Thanks(0)   Quote ub3rl337ch3ch Quote  Post ReplyReply Direct Link To This Post Topic: Datetime and SQL Server
    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


Edited by ub3rl337ch3ch - 29 May 2005 at 10:53pm
Back to Top
ub3rl337ch3ch View Drop Down
Senior Member
Senior Member
Avatar

Joined: 16 February 2005
Location: Australia
Status: Offline
Points: 341
Post Options Post Options   Thanks (0) Thanks(0)   Quote ub3rl337ch3ch Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.