用next_day得出本周的周一到周日的日期

来源:互联网 发布:辐射4 mac版 编辑:程序博客网 时间:2024/05/07 01:29

用next_day得出本周的周一到周日的日期

next_day()的语法格式:

next_day := next_day(date,day_of_the_week);

它用来返回从第一个参数指定的日期开始,第一次到达第二个参数(星期)的日期.

参数day_of_the_week可以是从1到7的数字,也可以是sunday...saturday之类的英语单词

 

例如:取本周一是哪一天,有如下两种写法。

SQL>select trunc(next_day(sysdate-7,'monday')) from dual;

SQL>select trunc(next_day(sysdate-7,2)) from dual;

 

取周日的写法:

SQL>select trunc(next_day(sysdate-1,'sunday')) from dual;

SQL>select trunc(next_day(sysdate-1,7)) from dual;

 

注意:周日是一周的第一天。

原创粉丝点击