龙盟编程博客 | 无障碍搜索 | 云盘搜索神器
快速搜索
主页 > 数据库类 > Oracle 技术 >

Oracle to_char 日期转换字符串语句分享(2)

时间:2014-08-13 02:25来源:网络整理 作者:网络 点击:
分享到:
2.查询某周的最后一天 select trunc(decode(ww, 53, to_date(yy || '3112', 'yyyyddmm'), to_date(yy || '-' || to_char(ww * 7), 'yyyy-ddd')), 'd') - 6 first_day from (select substr('2004-33', 1, 4)

2.查询某周的最后一天

select trunc(decode(ww, 53, to_date(yy || '3112', 'yyyyddmm'), to_date(yy || '-' || to_char(ww * 7), 'yyyy-ddd')), 'd') - 6 first_day 
from (select substr('2004-33', 1, 4) yy, to_number(substr('2004-33', 6)) ww 
from dual) 
select trunc(to_date(substr('2003-01',1,5)||to_char((to_number(substr('2003-01',6)))*7),'yyyy-ddd'),'d') last_day from dual 
select max(v_date) from 
(select (to_date('200408','yyyymm') + rownum) v_date 
from all_tables 
where rownum < 370) 
where to_char(v_date,'yyyy-iw') = '2004-33' 
精彩图集

赞助商链接