SQL 如何将数字(整数)转换为日期? [英] SQL How to convert number (integer) to date?

查看:100
本文介绍了SQL 如何将数字(整数)转换为日期?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用小型商业软件并导入到 SQL Server.但有数字:

I'm working with small commerce software and importing to SQL Server. But there are numbers:

75739
76910
73105
75821
75245
75605
77169
73265
75611
74073
77012

代表我认为的日期.

如何将这些数字转换为日期YYYY-MM-DDYYYYMMDD?

How to convert these numbers to date YYYY-MM-DD and YYYYMMDD?

推荐答案

基于 1900 年 1 月 1 日的 SQL Server 纪元(基准或零日期),这些日期在 22 世纪

Based on the SQL Server epoch (base or zero date) of 01 Jan 1900, these dates are in 22nd century

SELECT DATEADD(day, 75739, 0) -- 2107-05-15 00:00:00.000

还是基于日期时间的下限?这是 1960-ish,适用于出生日期

Or are they based on the lower bound of datetime? This is 1960-ish, which works for date of births

SELECT DATEADD(day, 75739, '17530101') -- 1960-05-15 00:00:00.000

tl;dr 需要更多信息.否则不要尝试

tl;dr more info needed. Otherwise don't even try

这篇关于SQL 如何将数字(整数)转换为日期?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆