Search code examples
sqldatetimeprestoamazon-athenadate-arithmetic

SQL to get next monday in Presto


I need to get the date for next Monday irrespective of which day the sql is executed.

I think the logic 7 - day_of_week(current_date)%7 + 1 would work, but then how to get the date.

select current_date;

    _col0
1   2019-11-16


select (7 - day_of_week(current_date)%7+1)


    _col0
1   2

Or is there any other better way to do the same.

I will appreciate any help!!


Solution

  • You could do:

    date_add(day, 8 - extract(day_of_week from current_date), current_date)