SergeRielau
Databricks Employee
Databricks Employee

TRy this:

CREATE OR REPLACE FUNCTION days(dt DATE) RETURN unix_date(dt) - unix_date(DATE'0001-01-01') + 1;

SELECT current_date, days(current_date); 

2023-03-09 738588

I verified on Db2 for LUW and it matches up.

View solution in original post