开发者

Convert int to datetime

开发者 https://www.devze.com 2022-12-28 05:50 出处:网络
how can i convert a field contain data 733803 as into 开发者_开发知识库be datetime on sql server?What data is 733803? Is it a unix timestamp?

how can i convert a field contain data 733803 as into 开发者_开发知识库be datetime on sql server?


What data is 733803? Is it a unix timestamp? If it is the answer is below.

select dateadd(ss, 733803, '1970-01-01')


You can simply cast from integer to datetime like so:

declare @outDate as datetime

set @outDate = CAST(@integerValue as datetime)

Of course, that presumes that your integers are valid sql integer representations of datetimes and will probably also depend upon regional settings of the servers you are running this on.

For example, the integer you provided converts to a date in 3909 on my sql server, so perhaps there is something else going on in the generation of that int?

0

精彩评论

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