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 nowminute from dual;
4.–獲取時間的秒:
select to_char(sysdate,』ss』) as nowsecond from dual;
5.–當前星期幾
select to_char(sysdate,』day』) from dual;
6.–本週整週日期(以週日為第一天算)
select trunc(sysdate,』d』), trunc(sysdate,』d』)+7 from dual;
7.–下週開始日期
select trunc(sysdate,』d』)+7 from dual;
下週整週日期
select trunc(sysdate,』d』)+7,trunc(sysdate,』d』)+14 from dual;
8.–本月開始日期
select trunc(sysdate,』mm』) from dual;
9.–本月結束日期
select last_day(trunc(sysdate))from dual;
10.–下個月開始日期
select add_months(trunc(sysdate, 『mm』), 1) from dual;
11.–本季開始日期
select trunc(sysdate,』q』)from dual;
12–本年開始日期
select trunc(sysdate,』yyyy』) from dual;
13–本年結束日期
select add_months(trunc(sysdate,』yyyy』),12)-1 from dual;
14.
select to_char(sysdate, 『iw』) as week, –今年已過周
to_char(sysdate, 『ww』) as week2, –周
to_char(sysdate, 『ddd』) as day, –今年已過天
to_char(sysdate, 『q』) as quarter – 今年已過季度
from dual;
注:ww的演算法為每年1月1日為第一周開始,date+6為每一周結尾
iw的演算法為星期一至星期日算一周,且每年的第乙個星期一為第一周
oracle特殊時間查詢
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 sysda...
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...
Oracle關於時間的各種處理
v base time0 date v base time date v starttime number 10 begin v base time0 to date 1970 01 01 00 00 00 yyyy mm dd hh24 mi ss v base time to date to c...