ITECH ITECH - 1 month ago 16
SQL Question

SQL SERVER DATETIME FORMAT

Studying SQL Server there is something I am not sure of:

A

datetime
field with the value:
2012-02-26 09:34:00.000


If I select out of the table using:

CAST(dob2 AS VARCHAR(12) ) AS d1


It formats it as:
Feb 26 2012


What I am unsure of his how or why SQL Server formats DateTime like that. If you use
datetime2
it does not - anyone know why?

Answer

The default date format depends on the language setting for the database server. You can also change it per session, like:

set language french
select cast(getdate() as varchar(50))
-->
févr 8 2013 9:45AM
Comments