Oracle获取当天,当月,当年的数据
来源:互联网 发布:淘宝上如何买到真牛排 编辑:程序博客网 时间:2024/05/20 05:53
between
to_date(to_char(sysdate,'yyyy-mm-dd') || ' 00:00:01','yyyy-mm-dd hh24:mi:ss') and
to_date(to_char(sysdate,'yyyy-mm-dd') || ' 23:59:59','yyyy-mm-dd hh24:mi:ss');
Oracle
字段类型为varchar2,格式要与格式化的样式匹配
当天
select * from 表名 where to_char(to_date(字段名,'yyyy-mm-dd hh24:mi:ss'),'dd')=to_char(sysdate,'dd')
当周
select * from 表名 where to_char(to_date(字段名,'yyyy-mm-dd hh24:mi:ss'),'iw')=to_char(sysdate,'iw')
当月
select * from 表名 where to_char(to_date(字段名,'yyyy-mm-dd hh24:mi:ss'),'mm')=to_char(sysdate,'mm')
当季度
select * from 表名 where to_char(to_date(字段名,'yyyy-mm-dd hh24:mi:ss'),'q')=to_char(sysdate,'q')
字段类型为date
当天
select * from 表名 where to_char(字段名,'dd')=to_char(sysdate,'dd')
当周
select * from 表名 where to_char(字段名,'iw')=to_char(sysdate,'iw')
当月
select * from 表名 where to_char(字段名,'mm')=to_char(sysdate,'mm')
当季度
select * from 表名 where to_char(字段名,'q')=to_char(sysdate,'q')
SQL
当天
select * from 表名 where DATEPART(dd,字段名) = DATEPART(dd, GETDATE()) and DATEPART(mm, 字段名) = DATEPART(mm, GETDATE()) and DATEPART(yy, 字段名) = DATEPART(yy, GETDATE())
当周
select * from 表名 where DATEPART(wk, 字段名) = DATEPART(wk, GETDATE()) and DATEPART(yy, 字段名) = DATEPART(yy, GETDATE())
当月
select * from 表名 where DATEPART(mm, 字段名) = DATEPART(mm, GETDATE()) and DATEPART(yy, 字段名) = DATEPART(yy, GETDATE())
当季度
select * from 表名 where DATEPART(qq, 字段名) = DATEPART(qq, GETDATE()) and DATEPART(yy,字段名) = DATEPART(yy, GETDATE()
1. 当天 createdtime 参数
select? * from tablename t?where where trunc(sysdate)=trunc(t.createdtime);
2.当月 createdtime 参数
select * from tablename t where t.createdtime>=trunc(SYSDATE, 'MM') and t.createdtime<=last_day(SYSDATE)
?
3.当年 createdtime 参数
select * from table t??where t.createtime>=trunc(sysdate,'YYYY')??and t.createtime<=add_month(trunc(sysdate,'YYYY'),12)-1
?
1. 当天 createdtime 参数
select? * from tablename t?where where trunc(sysdate)=trunc(t.createdtime);
2.当月 createdtime 参数
select * from tablename t where t.createdtime>=trunc(SYSDATE, 'MM') and t.createdtime<=last_day(SYSDATE)
?
3.当年 createdtime 参数
select * from table t??where t.createtime>=trunc(sysdate,'YYYY')??and t.createtime<=add_month(trunc(sysdate,'YYYY'),12)-1
1. 当天 createdtime 参数
select? * from tablename t?where where trunc(sysdate)=trunc(t.createdtime);
2.当月 createdtime 参数
select * from tablename t where t.createdtime>=trunc(SYSDATE, 'MM') and t.createdtime<=last_day(SYSDATE)
?
3.当年 createdtime 参数
select * from table t??where t.createtime>=trunc(sysdate,'YYYY')??and t.createtime<=add_month(trunc(sysdate,'YYYY'),12)-1
?
1. 当天 createdtime 参数
select? * from tablename t?where where trunc(sysdate)=trunc(t.createdtime);
2.当月 createdtime 参数
select * from tablename t where t.createdtime>=trunc(SYSDATE, 'MM') and t.createdtime<=last_day(SYSDATE)
?
3.当年 createdtime 参数
select * from table t??where t.createtime>=trunc(sysdate,'YYYY')??and t.createtime<=add_month(trunc(sysdate,'YYYY'),12)-1
- Oracle获取当天,当月,当年的数据
- Oracle获取当天,当月,当年的数据
- Oracle获取当天,当月,当年的数据
- oracle 查询当天、当月、当年范围的记录
- java 实现获取当天,当周,当月,当季,当年的时间段
- SQL SERVER中查询当天、当月、当年数据的SQL语句
- oracle 统计当年和当月数据
- oracle 求当天,当月,当星期数据
- 查询当年当月数据
- oracle获取当天数据
- oracle 获取 当年第一天 当月第一天
- sqlite 获取当天当周当月等数据
- MySQL查询当天当月数据
- java 根据年月日 获取当天是当年的第几天
- Sql 查询当天日期,查询当月日期,查询当年日期
- 使用sql 语句查询当月/当天/当周的数据
- mysql 查询当天当周当月的数据
- jquery获取当年月天数以及当月的最后一天|当月的天数
- VelocityTracker类的介绍和使用
- Collection和Collections的区别
- google测试第一题及
- 面向对象程序设计上机练习三(有默认参数的函数)
- Java-线程$等待唤醒机制(wait,notify)
- Oracle获取当天,当月,当年的数据
- Connection、PreparedStatement、Statement、ResultSet是JDBC编程常用的接口,请分别简述它们的作用?
- zoj 1524 - Supermarket
- 面向对象程序设计上机练习四(变量引用)
- 判断一个单链表是否有环及环的链接点
- hibernate 关联关系 一对一 外间关联 .
- 记忆化搜索
- 面向对象程序设计上机练习一(函数重载)
- 排序二叉树