[英]Microsoft SQL Server 2016 Date as Numerical Representation
Does anyone know if there is a way to get a number representation of a date, the same way DB2 does theirs?有谁知道是否有办法获得日期的数字表示,就像 DB2 一样?
https://www.ibm.com/docs/pl/db2-for-zos/11?topic=functions-days https://www.ibm.com/docs/pl/db2-for-zos/11?topic=functions-days
SELECT
POSTING_DATE,
DAYS(POSTING_DATE) AS NUMBER_REPRESENTATIOn
FROM core.env
enter image description here在此处输入图像描述
I've been searching but, cannot seem to find a solution.我一直在寻找,但似乎找不到解决方案。 Thanks!
谢谢!
Thedocumentation seemed pretty clear, you just have to translate the formula to use T-SQL syntax (where we measure the number of days between two dates using DATEDIFF
): 文档看起来很清楚,您只需翻译公式以使用 T-SQL 语法(我们使用
DATEDIFF
测量两个日期之间的天数):
DECLARE @d date = '20220808';
SELECT DATEDIFF(DAY, '00010101', @d) + 1;
Result:结果:
738,375
738,375
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.