--the first day
select trunc(sysdate,'q') from dual
-- 過去了多少天
select floor(sysdate- trunc(sysdate ,'q')+1) from dual
--乙個季度多少天
1. select last_day(to_date(to_char(sysdate,'yyyy-')||lpad(floor(to_number(to_char(sysdate,'mm'))/3)*3+3,2,'0')|| '-01','yyyy-mm-dd'))-
to_date(to_char(sysdate,'yyyy-')||lpad(floor(to_number(to_char(sysdate,'mm'))/3)*3+1,2,'0')||'-01','yyyy-mm-dd')+1
from dual
2.add_months(trunc(sysdate,'q'),3)-1-to_date(to_char(trunc(sysdate,'q'),'yyyy-mm-dd'),'yyyy-mm-dd')+1
--剩餘多少天
select last_day(to_date(to_char(sysdate,'yyyy-')||lpad(floor(to_number(to_char(sysdate,'mm'))/3)*3+3,2,'0')|| '-01','yyyy-mm-dd'))-
to_date(to_char(sysdate,'yyyy-')||lpad(floor(to_number(to_char(sysdate,'mm'))/3)*3+1,2,'0')||'-01','yyyy-mm-dd')+1 -
(floor(sysdate-
trunc(sysdate ,'q')+1))
from dual
--得到下月一日的日期
select add_months(trunc(to_date('2010-01-05','yyyy-mm-dd'), 'mm'), -1), from dual;
select to_date(to_char(add_months(trunc(sysdate, 'mm'), -1),'yyyy-mm')||'-'||to_char(sysdate,'dd'),'yyyy-mm-dd') from dual;
Oracle特殊字元查詢語句
1 如何判斷欄位的值裡面 那些資料報含小寫字母或大小字母 判斷欄位name的值裡面有小寫字母的記錄 方式1 select name from test where regexp like name,lower 方式2select name from test where regexp like na...
Oracle各種時間查詢
1.獲取時間的日 select to char sysdate,dd as nowday from dual 2.獲取時間的時 select to char sysdate,hh24 as nowhour from dual 3.獲取時間的分 select to char sysdate,mi as...
oracle 時間範圍查詢
時間範圍查詢 timestamp 時間查詢select from orders o where o.create time to timestamp 2018 01 21 10 22 58.714000 yyyy mm dd hh24 mi ss.ff and o.create time to ti...