Oracle PL/SQL之NEXT_DAY - 取得下一个星期几所在的日期

 NEXT_DAY(date,char):返回指定日期(由date指定)后的第一个星期几(由char指定)所在的日期,char也可用1~7替代,1表示星期日。

duzz$scott@orcl>select sysdate,to_char(sysdate,'day') weekday,next_day(sysdate,1) n_day,to_char(next_day(sysdate,1),'day') n_weekday from dual;

SYSDATE             WEEKDAY    N_DAY                N_WEEKDAY
------------------- ---------- -------------------- ----------
2011-08-22 23:01:18 monday     2011-08-28 23:01:18  sunday

Elapsed: 00:00:00.00
duzz$scott@orcl>select sysdate,to_char(sysdate,'day') weekday,next_day(sysdate,2) n_day,to_char(next_day(sysdate,2),'day') n_weekday from dual;

SYSDATE             WEEKDAY    N_DAY                N_WEEKDAY
------------------- ---------- -------------------- ----------
2011-08-22 23:04:26 monday     2011-08-29 23:04:26  monday

Elapsed: 00:00:00.00
duzz$scott@orcl>select sysdate,to_char(sysdate,'day') weekday,next_day(sysdate,3) n_day,to_char(next_day(sysdate,3),'day') n_weekday from dual;

SYSDATE             WEEKDAY    N_DAY                N_WEEKDAY
------------------- ---------- -------------------- ----------
2011-08-22 23:04:55 monday     2011-08-23 23:04:55  tuesday

Elapsed: 00:00:00.00
duzz$scott@orcl>select sysdate,to_char(sysdate,'day') weekday,next_day(sysdate,'monday') n_day,to_char(next_day(sysdate,'monday'),'day') n_weekday from dual;

SYSDATE             WEEKDAY    N_DAY                N_WEEKDAY
------------------- ---------- -------------------- ----------
2011-08-22 23:08:16 monday     2011-08-29 23:08:16  monday

Elapsed: 00:00:00.00
duzz$scott@orcl>


 REF:
http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/functions093.htm


原文链接: http://blog.csdn.net/t0nsha/article/details/6710181

你可能感兴趣的:(Oracle PL/SQL之NEXT_DAY - 取得下一个星期几所在的日期)