Hi Team,
I am working on migration from Sql server to databricks environment.
I encounter a challenge where Databricks and sql server giving different results for date difference function. Can you please help?
--SQL SERVER
SELECT DATEDIFF(MONTH , '2007-01-01' , '2007-02-28') ; --1
SELECT DATEDIFF(MONTH , '2007-01-30' , '2007-02-28') ; --1
SELECT DATEDIFF(MONTH , '2007-01-31' , '2007-02-28') ; --1
--Databricks
SELECT DATEDIFF(MONTH , '2007-01-01' , '2007-02-28') ; --1
SELECT DATEDIFF(MONTH , '2007-01-30' , '2007-02-28') ; --0
SELECT DATEDIFF(MONTH , '2007-01-31' , '2007-02-28') ; --0
select floor(months_between('2007-02-28', '2007-01-01')) --1
select floor(months_between('2007-02-28', '2007-01-30')) --0
select floor(months_between('2007-02-28', '2007-01-31')) --1