1、日期比较:
在今天之前:
select * from up_date where update < to_date('2007-09-07 00:00:00','yyyy-mm-dd hh24:mi:ss')
select * from up_date where update <= to_date('2007-09-07 00:00:00','yyyy-mm-dd hh24:mi:ss') 在今天只后:
select * from up_date where update > sysdate --- 与当前系统时间比较
select * from up_date where update >= to_date('2007-09-07 00:00:00','yyyy-mm-dd hh24:mi:ss') 精确时间:
select * from up_date where update = to_date('2007-09-07 00:00:00','yyyy-mm-dd hh24:mi:ss') 在某段时间内:
select * from up_date where update between to_date('2007-07-07 00:00:00','yyyy-mm-dd hh24:mi:ss') and to_date('2007-09-07 00:00:00','yyyy-mm-dd hh24:mi:ss')
select * from up_date where update < to_date('2007-09-07 00:00:00','yyyy-mm-dd hh24:mi:ss') and update > to_date('2007-07-07 00:00:00','yyyy-mm-dd hh24:mi:ss')
select * from up_date where update <= to_date('2007-09-07 00:00:00','yyyy-mm-dd hh24:mi:ss') and update >= to_date('2007-07-07 00:00:00','yyyy-mm-dd hh24:mi:ss')
2、获取系统日期:
select sysdate from dual;
3、日期格式化:
格式化日期: TO_CHAR(SYSDATE(),'YY/MM/DD HH24:MI:SS) 或 TO_DATE(SYSDATE(),'YY/MM/DD HH24:MI:SS)
格式化数字: TO_NUMBER
注:TO_CHAR 把日期或数字转换为字符串 TO_CHAR(number, '格式') 、TO_CHAR(salary, '$99,999.99') 、TO_CHAR(date, '格式')
TO_DATE 把字符串转换为数据库中的日期类型TO_DATE(char, '格式')
TO_NUMBER 将字符串转换为数字 TO_NUMBER(char, '格式')