开发者

date in sql server 2008

开发者 https://www.devze.com 2023-02-15 15:16 出处:网络
d = 10 m = 2 y = 2011 I would like to create an Sql Date ty开发者_运维技巧pe using the above info ?

d = 10 m = 2 y = 2011

I would like to create an Sql Date ty开发者_运维技巧pe using the above info ? How ?


DECLARE @d INT = 10,
        @m INT = 2,
        @y INT = 2011

SELECT DATEADD(DAY, @d - 1, 
       DATEADD(MONTH, @m - 1, 
       DATEADD(YEAR, @y - 1, CAST('00010101' AS DATE))))  


if the column type is DateTime try to use the following:

set dateformat dmy

insert into TABLE_NAME (COL_NAME) VALUES ('10.02.2011')
0

精彩评论

暂无评论...
验证码 换一张
取 消