Does anyone know if there is a way to get a number representation of a date, the same way DB2 does theirs?
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
I've been searching but, cannot seem to find a solution. Thanks!
CodePudding user response:
The documentation 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
):
DECLARE @d date = '20220808';
SELECT DATEDIFF(DAY, '00010101', @d) 1;
Result:
738,375