mysql时间——查询上周、月、季度、年和本周、月、季度、年
来源:互联网 发布:novesta淘宝 编辑:程序博客网 时间:2024/05/19 16:48
select * from ht_invoice_information where WEEKOFYEAR(create_date)=WEEKOFYEAR(NOW());
#查询上周记录select * from ht_invoice_information where create_date>=date_add(now(),interval -(8 + weekday(now())) day)
and create_date<=date_add(now(),interval -(1 + weekday(now())) day);
#或者
select * from `ht_invoice_information` where WEEKOFYEAR(create_date)=WEEKOFYEAR(DATE_SUB(now(),INTERVAL 1 week));
#查询本月数据
select * from ht_invoice_information where MONTH(create_date)=MONTH(NOW()) and year(create_date)=year(now());
#查询上月数据
select * from ht_invoice_information where create_date<=last_day(date_add(now(),interval -1 MONTH))
and create_date>=DATE_FORMAT(concat(extract(year_month from date_add(now(),interval -1 MONTH)),'01'),'%Y-%m-%d');
#或者
select * from `ht_invoice_information` where MONTH(create_date)=MONTH(DATE_SUB(NOW(),interval 1 month))
and year(create_date)=year(now());
#查询本季度数据
select * from `ht_invoice_information` where QUARTER(create_date)=QUARTER(now());
#查询上季度数据
select * from `ht_invoice_information` where QUARTER(create_date)=QUARTER(DATE_SUB(now(),interval 1 QUARTER));
#查询本年数据
select * from `ht_invoice_information` where YEAR(create_date)=YEAR(NOW());
#查询上年数据
select * from `ht_invoice_information` where year(create_date)=year(date_sub(now(),interval 1 year));
本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/flm_0722/archive/2009/12/08/4961758.aspx
- mysql时间——查询上周、月、季度、年和本周、月、季度、年
- mysql查询上周、月、季度、年和本周、月、季度、年
- mysql查询上周、月、季度、年和本周、月、季度、年
- MySQL 按周,月,季度,年查询
- SQL 按周,月,季度,年查询统计数据
- SQL 按周,月,季度,年查询统计数据
- SQL 按周,月,季度,年查询统计数据
- mysql 月 周 季度
- mysql按年,季度,月,周,时间统计数据
- ORACLE时间字段取年、月、日、季度
- 时间控件:my97DatePicker选择年、季度、月、周、日
- 实现按周,月,季度,年查询统计数
- oracle 实现按周,月,季度,年查询统计数据(收集)
- javascript实现年、季度、月、时间段的查询条件切换
- oracle 实现按周,月,季度,年查询统计数据(收集)
- oracle 实现按周,月,季度,年查询统计数据
- Oracle 实现按周、月、季度、年查询统计数据
- MYSQL 查询今天,昨天,N天,本周,上周,季度,本年,上年
- 利用QT来实现读取电脑屏幕
- C++ next_permutation 穷举每一种组合
- 关于一道简单的Java 基础面试题的剖析: short s1=1;s1 = s1 +1会报错吗?
- SylixOS 经得起检验的国产操作系统 (六)
- Android设置Dialog点击按钮也不会关闭
- mysql时间——查询上周、月、季度、年和本周、月、季度、年
- 【Lua】【4】Lua之——高级函数和控制结构
- Windows BAT
- 使用PowerPoint输出高质量图片
- 控制打印页面某一部分
- thinkphp 整合swfupload
- 办公内线电话快速搭建方案之i话
- spring security
- 最新的maven国内镜像使用手册