常用sql(oracle)的时间查询

按日期查询:

SELECT * FROM ge_bill_biz_type WHERE biz_type='29' and to_char(created_time,'yyyy-mm-dd')='2021-09-18'

sql server 按时间段查询

oracle时间的获取

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

十天前-今天内的所有记录(例:2021-09-18(含)至2021-09-28(含)):

select * from ge_bill_info where created_time>=trunc(sysdate-10,'dd')

 

参考:oracle查询本月第一天_oracle获取本月第一天和最后一天及Oracle trunc()函数的用法..._weixin_39566593的博客-CSDN博客

posted @ 2021-11-25 15:36  小丸子姐姐  阅读(3038)  评论(0编辑  收藏  举报