Skip to content
Advertisement

Hive trunc date format issues

I am trying to convert GP to Hive migration logic but below statement giving the wrong output while execute query:

output for GP : 2021-12-31

similar if we converted Hive query

out put if Hive query : 2022-01-02

i could see the difference of the date. please help me.

Thanks

Advertisement

Answer

You are subtracting interval 0 months and 1 day in the first query, in second query you are adding 0 months (it makes no sense) and adding 1 day (not subtracting). If you want to do the same as in GP query in Hive just subtract 1 day, it will work the same:

Or the same using interval:

Or one more possible alternative:

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement