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
SSC Journeyman
SSC Journeyman (94 reputation)SSC Journeyman (94 reputation)SSC Journeyman (94 reputation)SSC Journeyman (94 reputation)SSC Journeyman (94 reputation)SSC Journeyman (94 reputation)SSC Journeyman (94 reputation)SSC Journeyman (94 reputation)

Group: General Forum Members
Points: 94 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
Hall of Fame
Hall of Fame (3.3K reputation)Hall of Fame (3.3K reputation)Hall of Fame (3.3K reputation)Hall of Fame (3.3K reputation)Hall of Fame (3.3K reputation)Hall of Fame (3.3K reputation)Hall of Fame (3.3K reputation)Hall of Fame (3.3K reputation)

Group: General Forum Members
Points: 3259 Visits: 961
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
SSCertifiable
SSCertifiable (6.2K reputation)SSCertifiable (6.2K reputation)SSCertifiable (6.2K reputation)SSCertifiable (6.2K reputation)SSCertifiable (6.2K reputation)SSCertifiable (6.2K reputation)SSCertifiable (6.2K reputation)SSCertifiable (6.2K reputation)

Group: General Forum Members
Points: 6211 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
SSC-Dedicated
SSC-Dedicated (35K reputation)SSC-Dedicated (35K reputation)SSC-Dedicated (35K reputation)SSC-Dedicated (35K reputation)SSC-Dedicated (35K reputation)SSC-Dedicated (35K reputation)SSC-Dedicated (35K reputation)SSC-Dedicated (35K reputation)

Group: General Forum Members
Points: 35816 Visits: 11933
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-Enthusiastic
SSC-Enthusiastic (177 reputation)SSC-Enthusiastic (177 reputation)SSC-Enthusiastic (177 reputation)SSC-Enthusiastic (177 reputation)SSC-Enthusiastic (177 reputation)SSC-Enthusiastic (177 reputation)SSC-Enthusiastic (177 reputation)SSC-Enthusiastic (177 reputation)

Group: General Forum Members
Points: 177 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
SSC Journeyman
SSC Journeyman (94 reputation)SSC Journeyman (94 reputation)SSC Journeyman (94 reputation)SSC Journeyman (94 reputation)SSC Journeyman (94 reputation)SSC Journeyman (94 reputation)SSC Journeyman (94 reputation)SSC Journeyman (94 reputation)

Group: General Forum Members
Points: 94 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
SSCrazy Eights
SSCrazy Eights (8.9K reputation)SSCrazy Eights (8.9K reputation)SSCrazy Eights (8.9K reputation)SSCrazy Eights (8.9K reputation)SSCrazy Eights (8.9K reputation)SSCrazy Eights (8.9K reputation)SSCrazy Eights (8.9K reputation)SSCrazy Eights (8.9K reputation)

Group: General Forum Members
Points: 8911 Visits: 2157
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
SSCrazy Eights
SSCrazy Eights (9.5K reputation)SSCrazy Eights (9.5K reputation)SSCrazy Eights (9.5K reputation)SSCrazy Eights (9.5K reputation)SSCrazy Eights (9.5K reputation)SSCrazy Eights (9.5K reputation)SSCrazy Eights (9.5K reputation)SSCrazy Eights (9.5K reputation)

Group: General Forum Members
Points: 9459 Visits: 1700
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