SQL将在下周一在Presto获得

无论执行SQL的那一天,我都需要获取下周一的日期。

我认为逻辑7 - day_of_week(current_date)%7 + 1可以工作,但是如何获取日期。

select current_date;

    _col0
1   2019-11-16


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


    _col0
1   2

或者还有其他更好的方法可以做到这一点。

我将不胜感激!

yechuan09 回答:SQL将在下周一在Presto获得

您可以这样做:

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

您可以使用date_trunc来获取当前一周的星期一并为其添加7天:

presto> select date_trunc('week',current_date) + interval '7' day;

   _col0
------------
 2019-11-18
(1 row)
本文链接:https://www.f2er.com/3091879.html

大家都在问