我有一个日期列表。我想返回上个月的最后一个日期,如下例所示:
date lastdayofmonthprior
'2018-04-03' '2018-03-31'
Run Code Online (Sandbox Code Playgroud)
我试过了date_trunc('month', date('2018-04-03'))-1,但是,我收到此错误:
'-' cannot be applied to date, integer
Run Code Online (Sandbox Code Playgroud)
我猜我无法对 Presto 中的日期进行算术运算。
您可以在 Presto 中使用 DATE_ADD:
DATE_ADD('day', -1, date_trunc('month', date('2018-04-30')))
Run Code Online (Sandbox Code Playgroud)