且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在 SQL Server 2008 中将 int 转换为日期

更新时间:2022-11-01 13:14:30

您不能将整数值直接转换为日期,但可以先将其转换为日期时间,然后再转换为日期类型

You can't convert an integer value straight to a date but you can first it to a datetime then to a date type

select cast(40835 as datetime)

然后转换为日期(SQL 2008)

and then convert to a date (SQL 2008)

select cast(cast(40835 as datetime) as date)

干杯