How to convert the sequential number into date format using SQL/Python?

Viewed 79

In the retail dataset(CSV), I have a column "Day" and it has value starting from 1 to 712 (around two years of data). I want to convert it into a "yyyy-MM-dd" format. The starting timestamp is 2017-01-01.

ACTUAL:

Day, Prod_id, Sales
1, 23232, 34.5
1, 34522, 76
2, 53436, 45.7
2, 67353, 12.5
.....
.....
712, 35357, 67.2

EXPECTED:

Day, Prod_id, Sales, TS
1, 23232, 34.5, 2017-01-01
1, 34522, 76, 2017-01-01
2, 53436, 45.7, 2017-01-02
2, 67353, 12.5, 2017-01-02
.....
.....
712, 35357, 67.2, 2018-12-25

Please help me to achieve this.

1 Answers

In Hive use date_add('2017-01-01', day) as ts

Related