Reputation: 45
for Example there is a date '2021-08-21', I need to convert it to '2021-05-01' I am confused with right functions to use as I want it to use it in Apache Spark SQL.
Upvotes: 0
Views: 1533
Reputation: 14895
You can use add_month first and then use date_trunc to get the first day of the result of add_month
.
select date_trunc('MONTH', add_months(date, -3))
Upvotes: 1