--timestamp
select to_char(sysdate, 'yyyy-mm-dd hh24:mi:ss') current_date,
(sysdate - 8 / 24 - to_date('1970-01-01', 'yyyy-mm-dd')) * 86400000 current_milli
from dual;
--timestamp from the special day
select to_number(to_date('2011-2-20','yyyy-mm-dd') - to_date('1970-01-01 8:0:0', 'yyyy-mm-dd hh24:mi:ss')) * 24*60*60*1000 from dual;
--
1. to_date('2010-12-01', 'yyyy-mm-dd');
2. to_char(sysdate, 'yyyy-mm-dd hh24:mi:ss');
3. trunc(sysdate);
4. where createtime < to_date('2010-12-01', 'yyyy-mm-dd') and createtime >= to_date('2010-11-30', 'yyyy-mm-dd');
select to_char(sysdate, 'yyyy-mm-dd hh24:mi:ss') current_date,
(sysdate - 8 / 24 - to_date('1970-01-01', 'yyyy-mm-dd')) * 86400000 current_milli
from dual;
--timestamp from the special day
select to_number(to_date('2011-2-20','yyyy-mm-dd') - to_date('1970-01-01 8:0:0', 'yyyy-mm-dd hh24:mi:ss')) * 24*60*60*1000 from dual;
--
1. to_date('2010-12-01', 'yyyy-mm-dd');
2. to_char(sysdate, 'yyyy-mm-dd hh24:mi:ss');
3. trunc(sysdate);
4. where createtime < to_date('2010-12-01', 'yyyy-mm-dd') and createtime >= to_date('2010-11-30', 'yyyy-mm-dd');
SQL日期时间操作与日期比较
本文详细介绍了SQL中如何使用日期时间函数进行日期转换、时间戳计算,并演示了如何通过日期比较语句筛选特定日期范围内的记录。适用于数据库管理和查询优化。
1493

被折叠的 条评论
为什么被折叠?



