How to convert int to date in SQL Server 2008

前端 未结 5 921
情歌与酒
情歌与酒 2020-12-09 18:50

I am using MS SQL Server 2008, and in a table I have column idate as date but in the integer format. But in the query I want that in the date format. Is it possible to conve

5条回答
  •  -上瘾入骨i
    2020-12-09 19:33

    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)

    and then convert to a date (SQL 2008)

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

    cheers

提交回复
热议问题