Solution of date issues in SQL Server

xiaoxiao2021-03-06  42

In MS SQLServer, only the datetime type, date and time are together, such as 2004-12-19 23:12:20,

Sometimes, in the SQL statement, you will be more troublesome, but there is also the following method, summarize

For example, it is required to obtain records of 2004-19, so

A) WHERE datediff (DD, DateTimeColumn, '12 / 19/2004 ') = 0

B) WHERE CONVERT (VARCHAR (20), DateTimeColumn, 101) = '12 / 191/2004 'c) Where DateTimeColumn Like '12 / 19/2004%'

D) Where Year (datetimecolumn) = 2004 and month (datetimecolumn) = 12 and day (datetimolumn) = 19

转载请注明原文地址:https://www.9cbs.com/read-79000.html

New Post(0)