21驗證trunc()函數
oracle
ppas
22驗證mod()函數
日期函數
23取得目前的系統時間
24修改日期顯示格式
25查詢距離今天為止3天之後及3天之前的日期
26查詢出每個雇員到今天為止的雇傭天數,以及十天前每個雇員的雇傭天數
27在查詢結果中使用trunc()函數完成将小數點之後的内容全部清除
28驗證add_months()函數
29要求顯示所有雇員在被雇傭三個月之後的日期
30驗證next_day()函數
31驗證last_day()函數
32查詢所有是在其雇傭所在月的倒數第三天被公司雇傭的完整雇員資訊
33查詢出每個雇員的編号,姓名,雇傭日期,雇傭的月數,及年份
34查詢出每個雇員的編号,姓名,雇傭日期,已雇傭的年數、月數、天數
35從日期時間中取出年、月、日資料
36從時間戳中取出年、月、日、時、分、秒
37取得時間間隔
scott=# select extract(day from
scott(# to_timestamp('1982-08-13 12:17:57','yyyy-mm-dd hh24:mi:ss')
scott(# - to_timestamp('1981-09-27 09:08:33','yyyy-mm-dd hh24:mi:ss')) days ,
scott-# extract(hour from datetime_one - datetime_two) hours ,
scott-# extract(minute from datetime_one - datetime_two) minutes ,
scott-# extract(second from datetime_one - datetime_two) seconds
scott-# from (
scott(# select to_timestamp('1982-08-13 12:17:57','yyyy-mm-dd hh24:mi:ss') datetime_one ,
scott(# to_timestamp('1981-09-27 09:08:33','yyyy-mm-dd hh24:mi:ss') datetime_two
scott(# from dual) ;
days
hours
minutes
seconds
320
3
9
24
(1 row)
sql> select
2 extract(day from to_timestamp('1982-08-13 12:17:57','yyyy-mm-dd hh24:mi:ss')
3 - to_timestamp('1981-09-27 09:08:33','yyyy-mm-dd hh24:mi:ss')) days
4 from dual ;
scott=# select
scott-# extract(day from to_timestamp('1982-08-13 12:17:57','yyyy-mm-dd hh24:mi:ss')
scott(# - to_timestamp('1981-09-27 09:08:33','yyyy-mm-dd hh24:mi:ss')) days
scott-# from dual ;
sql> select sysdate 目前系統時間,to_char(sysdate,'yyyy-mm-dd') 格式化日期,
2 to_char(sysdate,'yyyy-mm-dd hh24:mi:ss') 格式化日期時間,
3 to_char(sysdate,'fmyyyy-mm-dd hh24:mi:ss') 去掉前導0的日期時間
4 from dual;
目前系統時間 格式化日期 格式化日期時間
------------ -------------------- --------------------------------------
21-jun-16 2016-06-21 2016-06-21 17:52:44
2016-6-21 17:52:44
scott=# select sysdate 目前系統時間,to_char(sysdate,'yyyy-mm-dd') 格式化日期,
scott-# to_char(sysdate,'yyyy-mm-dd hh24:mi:ss') 格式化日期時間,
scott-# to_char(sysdate,'fmyyyy-mm-dd hh24:mi:ss') 去掉前導0的日期時間
scott-# from dual;
21-jun-16 09:50:48
2016-06-21
2016-06-21 09:50:48
2016-6-21 9:50:48
sql> select sysdate 目前系統時間,to_char(sysdate,'year-month-dy') 格式化日期
2 from dual;
21-jun-16
twenty sixteen-june -tue
scott=# select sysdate 目前系統時間,to_char(sysdate,'year-month-dy') 格式化日期
21-jun-16 10:05:55
twenty sixteen-june -tue