SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


SQL 2008 Default DateTime format


SQL 2008 Default DateTime format

Author
Message
mirzakhalid82
mirzakhalid82
Grasshopper
Grasshopper (14 reputation)Grasshopper (14 reputation)Grasshopper (14 reputation)Grasshopper (14 reputation)Grasshopper (14 reputation)Grasshopper (14 reputation)Grasshopper (14 reputation)Grasshopper (14 reputation)

Group: General Forum Members
Points: 14 Visits: 14
Hi All
I need to change the SQL 2008 Default DateTime format from
YYYY-mm-dd HH:MM:SS TO dd/mm/yyyy hh:mm:ss
Please help I am stuck now
One other thing I am migrating From SQL 2000 and SQL 2005 to SQL 2008.
Kind Regards
Stefan_G
Stefan_G
SSC-Addicted
SSC-Addicted (495 reputation)SSC-Addicted (495 reputation)SSC-Addicted (495 reputation)SSC-Addicted (495 reputation)SSC-Addicted (495 reputation)SSC-Addicted (495 reputation)SSC-Addicted (495 reputation)SSC-Addicted (495 reputation)

Group: General Forum Members
Points: 495 Visits: 960
Exactly what are you trying to do ?

Are you trying to convert from a string to a date, or from a date to a string ?

Is the conversion done inside a stored procedure, or is it done in a client application ?
Ben Teraberry
Ben Teraberry
UDP Broadcaster
UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)

Group: General Forum Members
Points: 1491 Visits: 1199
If you are concerned about formatting output, you would be far better off handling all of that through whatever application you're using for the user interface. If you must pre-format in SQL Server, take a look at the CONVERT function in Books Online.

If you are having issues with how SQL Server is interpreting inputted dates, take a look at this article.

└> bt


Forum Etiquette: How to post data/code on a forum to get the best help
Michael Valentine Jones
Michael Valentine Jones
SSCertifiable
SSCertifiable (5.7K reputation)SSCertifiable (5.7K reputation)SSCertifiable (5.7K reputation)SSCertifiable (5.7K reputation)SSCertifiable (5.7K reputation)SSCertifiable (5.7K reputation)SSCertifiable (5.7K reputation)SSCertifiable (5.7K reputation)

Group: General Forum Members
Points: 5676 Visits: 11771
If SQL Server is conveting a string to DATETIME, there are only 2 unambiguous formats that SQL Server will always parse correctly:
'YYYYMMDD HH:MM:SS:mmm', example: '20100617 15:46:59.997'
'YYYY-MM-DDTHH:MM:SS:mmm', example: '2010-06-17T15:46:59.997'

Any other format can have problems, depending on the settings of DATEFORMAT and LANGUAGE.
nikhil0416
nikhil0416
SSC Rookie
SSC Rookie (25 reputation)SSC Rookie (25 reputation)SSC Rookie (25 reputation)SSC Rookie (25 reputation)SSC Rookie (25 reputation)SSC Rookie (25 reputation)SSC Rookie (25 reputation)SSC Rookie (25 reputation)

Group: General Forum Members
Points: 25 Visits: 8
As far as I know, upgrading the SQL Server does not require changing the default format of dates :-) Why do you need to do it?
mirzakhalid82
mirzakhalid82
Grasshopper
Grasshopper (14 reputation)Grasshopper (14 reputation)Grasshopper (14 reputation)Grasshopper (14 reputation)Grasshopper (14 reputation)Grasshopper (14 reputation)Grasshopper (14 reputation)Grasshopper (14 reputation)

Group: General Forum Members
Points: 14 Visits: 14
Hi All
Thank you for you reply. The Whole story is this. I am migrating my online systems from Windows Server 2003 to Win Server 2008 and SQL Server 2000 to Server 2008. Everything was fine but a date foremat wasnt good. Because in SQL 2000 date format was "dd/mm/yyyy" and in 2008 it is "yyyy-mm-dd" and when i was trying to insert the valuse into DB table from existing huge online system it was sending a the conversion error.

BUT EVERY THING IS SORTED NOW. I JUST CHANGE THE LANGUAGE OF LOGIN FROM ENGLISH TO BRITISH ENGLISH.
call.copse
call.copse
Hall of Fame
Hall of Fame (3.8K reputation)Hall of Fame (3.8K reputation)Hall of Fame (3.8K reputation)Hall of Fame (3.8K reputation)Hall of Fame (3.8K reputation)Hall of Fame (3.8K reputation)Hall of Fame (3.8K reputation)Hall of Fame (3.8K reputation)

Group: General Forum Members
Points: 3782 Visits: 1921
Thanks for this thread. I had a similar issue when I migrated a database to a new 2008 server. A pre-existing login had the wrong language causing the issues above, this thread made me check and realise the problem.

BTW much as I respect you Mr Celko, you are overly harsh above - I am fully cognisant of the correct way to do dates, unfortunately many of us have to deal with non-ideal code we cannot change and that we need to keep working, much against our preferences.
Lempster
Lempster
Hall of Fame
Hall of Fame (3.2K reputation)Hall of Fame (3.2K reputation)Hall of Fame (3.2K reputation)Hall of Fame (3.2K reputation)Hall of Fame (3.2K reputation)Hall of Fame (3.2K reputation)Hall of Fame (3.2K reputation)Hall of Fame (3.2K reputation)

Group: General Forum Members
Points: 3179 Visits: 1657
call.copse (2/27/2014)
BTW much as I respect you Mr Celko, you are overly harsh above - I am fully cognisant of the correct way to do dates, unfortunately many of us have to deal with non-ideal code we cannot change and that we need to keep working, much against our preferences.

+ 1

You might want to read the ANSI/ISO Standards

..particularly if you have trouble sleeping ;-)
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search