这里简单列几个应用示例:
如果您的答案与我有差异,请注意这几个参数的设置
① nls_date_format
② nls_language
③ nls_territory
与指定日期在同一周,周1的日期是
idle> select to_date(\'2013-1-4\',\'yyyy-mm-dd\')-to_char(to_date(\'2013-1-4\',\'yyyy-mm-dd\'),\'d\')+2 from dual;
TO_DATE(\'2013-1-4\',
-------------------
2012-12-31 00:0:0
idle> select trunc(to_date(\'2013-1-4\',\'yyyy-mm-dd\'),\'d\') +1 from dual;
TRUNC(TO_DATE(\'2013
-------------------
2012-12-31 00:0:0
idle> select next_day(to_date(\'2013-1-4\', \'yyyy-mm-dd\') - 7, \'星期一\') from dual;
NEXT_DAY(TO_DATE(\'2
-------------------
2012-12-31 00:0:0
指定日期当月最后一个星期天
idle> select next_day(trunc(to_date(\'2012-12-4\', \'yyyy-mm-dd\'), \'month\')+31-7,\'星期日\') from dual;
NEXT_DAY(TRUNC(TO_D
-------------------
2012-12-30 00:0:0
今年第127天是几号
idle> select to_date(\'127\',\'ddd\') from dual;
TO_DATE(\'127\',\'DDD\'
-------------------
2013-5-07 00:0:0
转载于:http://blog.itpub.net/26515977/viewspace-1207948/