oracle 查询 过去时间的记录
2014-04-21 11:30
267 查看
查询 昨天的记录:
select * from [table_name] where [create_date]= sysdate-1 --昨天上午10点的记录 select * from [table_name] where [create_date]=trunc(sysdate-1) + 10/24 --上个月的记录 select * from [table_name] where [create_date] = to_date(to_char(sysdate,'yyyy') || to_char(sysdate,'mm')-1 || to_char(sysdate,'dd'),'yyyy-mm-dd') select to_char(trunc(add_months(last_day(sysdate), -1) + 1), 'yyyy-mm-dd') "本月第一天", to_char(last_day(sysdate), 'yyyy-mm-dd') "本月最后一天" --Oracle trunc()函数的用法 /**************日期********************/ 1.select trunc(sysdate) from dual --2011-3-18 今天的日期为2011-3-18 2.select trunc(sysdate, 'mm') from dual --2011-3-1 返回当月第一天. 3.select trunc(sysdate,'yy') from dual --2011-1-1 返回当年第一天 4.select trunc(sysdate,'dd') from dual --2011-3-18 返回当前年月日 5.select trunc(sysdate,'yyyy') from dual --2011-1-1 返回当年第一天 6.select trunc(sysdate,'d') from dual --2011-3-13 (星期天)返回当前星期的第一天 7.select trunc(sysdate, 'hh') from dual --2011-3-18 14:00:00 当前时间为14:41 8.select trunc(sysdate, 'mi') from dual --2011-3-18 14:41:00 TRUNC()函数没有秒的精确 /***************数字********************/ /* TRUNC(number,num_digits) Number 需要截尾取整的数字。 Num_digits 用于指定取整精度的数字。Num_digits 的默认值为0。 TRUNC()函数截取时不进行四舍五入 */
相关文章推荐
- oracle 查询 过去时间的记录
- 分组查询取最大时间记录的方法Oracle
- Oracle查询一批数据,某字段的内容有重复数据,怎样取相同的记录中时间最近的一条
- oracle 的sql,查询时间为某年某月某日某时某分某秒等的记录,data或者TIMESTAMP(6)类型的字段
- 分组查询取最大时间记录的方法Oracle .
- 查询oracle下没有时间戳的表中的记录插入时间
- oracle 查询大于某个时间的记录
- ORACLE 查询大于某个时间的记录
- oracle下查询某条记录的插入时间
- oracle 如何查询过去某个时间点的记录(应用于某个时间点的误操作,回滚到之前的操作)
- oracle 当查询结果有重复记录时 选择时间最近的一条
- 查询oracle下没有时间戳的表中的记录插入时间
- Oracle查询重复数据并删除,只保留一条记录
- Oracle千万条记录插入与查询小结
- Oracle 查询今天、昨日、本周、本月和本季度的所有记录
- Oracle查询前10条记录及分页查询(第5条到第10记录)
- oracle 查询已有记录,上一条记录,下一条记录
- 查询oracle 数据库某时刻的历史记录
- Oracle 查询并删除重复记录的SQL语句
- Oracle生成查询包括对应于所有数据表记录语句中指定的字段名