I have a list of dates. I would like to return the last date of the month prior like the below example:
date lastdayofmonthprior
'2018-04-03' '2018-03-31'
I have tried date_trunc('month', date('2018-04-03'))-1
, however, I get this error:
'-' cannot be applied to date, integer
I'm guessing I can't do arithmetic to a date in Presto.
You can use DATE_ADD in Presto:
DATE_ADD('day', -1, date_trunc('month', date('2018-04-30')))