赞
踩
select current_date;--当天
select to_char(current_date + interval '-1 day', 'yyyyMMdd');--昨天
select to_char(current_date + interval '-1 week', 'yyyyMMdd');--上周
select to_char(current_date + interval '-1 month', 'yyyyMMdd');--上月
select to_char(current_date + interval '-1 year', 'yyyyMMdd');--上年
select trunc(current_date , 'iw');-- 周一
select trunc(current_date + 7, 'iw')-1; -- 周末
select to_char(date_trunc('week', current_date), 'yyyyMMdd'); --周一
select to_char(date_trunc('week', current_date)+ interval '+ 6 day', 'yyyyMMdd'); --周末
select trunc(current_date , 'mm');-- 月初
select to_char(date_trunc('month', current_date), 'yyyyMMdd'); --月初
select to_char(date_trunc('month', current_date)+ interval '+1 month' + interval '-1 day', 'yyyyMMdd');--月末
select to_char(date_trunc('year', current_date), 'yyyyMMdd'); --年初
select to_char(date_trunc('year', current_date)+ interval '+1 year' + interval '-1 day', 'yyyyMMdd');--年末
select to_char(current_date , 'yyyy' || '"0"' || 'q');--当季
select to_char(add_months(current_date , +3), 'yyyy' || '"0"' || 'q');--下季
select to_char(add_months(current_date , +6), 'yyyy' || '"0"' || 'q');--下下季
select to_char(add_months(current_date , +9), 'yyyy' || '"0"' || 'q');--下下下季
select LAST_DAY(current_date)--月末
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。