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