SQL Server Express Date Format

In the sql server 2005 table, I have a date column in the format dd / mm / yyyy. But everything on the 2008 sql server is yyyy-mm-dd.

Where can I change the format of dates stored in 2008 compared to 2005?

Thanks,

+3
source share
4 answers

Datetime types are always physically stored in the same format. It uses 8 bytes, the first 4 bytes are ints that store days before or after the base date 1/1/1900, and the 2nd 4 bytes are ints that represent the number 1/300 of a second from midnight.See here for for more information - http://msdn.microsoft.com/en-us/library/ms187819(SQL.90).aspx .

When you are viewing data, you can change the way data is presented using SET DATEFORMAT or using CONVERT . Technet has a good list of datetime functions to use with T-SQL.

+3
source
SELECT CONVERT(DATETIME,'13/04/2006',103)

Read more about date and time formats here .

+2
source

, DateTime , Sql, .
Sql Management Studio, Database, Properties, Options, Collation.
, , .


, , , . , , . SQL, , , "", " ".
, .

+1
source

Here are some other good links to crazy things people expect to do with datetime "strings":

http://sqlblog.com/blogs/aaron_bertrand/archive/2009/10/16/bad-habits-to-kick-mishandling-date-range-queries.aspx

And some more additional information about date / time types:

http://www.karaszi.com/SQLServer/info_datetime.asp

0
source

Source: https://habr.com/ru/post/1718473/


All Articles