Oracle中日期作为前提的查询有:1、局限日期的查询,代码为【where g_time between to_date()and to_date()】;2、即是某个日期的查询;3、当前日期的头几天和后几天的数据查询。
Oracle中日期作为前提的查询有:
1.局限日期的查询:
select * from goods
where g_time between
to_date('2018/12/26 10:01:59','yyyy-MM-dd hh:mi:ss')
and to_date('2018/12/26 10:05:17',' yyyy-MM-dd hh:mi:ss');
2.即是某个日期的查询:
select * from goods
where g_time=to_date('2018/12/26 10:05:17','yyyy-MM-dd hh:mi:ss');
3.当前日期的头几天和后几天的数据查询:
select * from goods
where g_time >= trunc(sysdate)-6 and < trunc(sysdate)-3;
为何要用trunc(sysdate)呢
由于当前时候平常不会正好是0点,比方当前是11点,-6就是6天前的11 点入手下手
4.查询出每月倒数第三天上架的商品信息:
select g.* from goods g where g.g_time=last_day(g.g_time)-2;
相干进修引荐:oracle数据库进修教程
以上就是Oracle中日期作为前提的查询有哪些?的细致内容,更多请关注ki4网别的相干文章!
收藏 | 0