mysql查询上周、月、季度、年和本周、月、季度、年
来源:互联网 发布:修改软件使用时间 编辑:程序博客网 时间:2024/05/07 01:14
查询本周记录
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))
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))
- mysql查询上周、月、季度、年和本周、月、季度、年
- mysql查询上周、月、季度、年和本周、月、季度、年
- mysql时间——查询上周、月、季度、年和本周、月、季度、年
- MySQL 按周,月,季度,年查询
- SQL 按周,月,季度,年查询统计数据
- SQL 按周,月,季度,年查询统计数据
- SQL 按周,月,季度,年查询统计数据
- mysql 月 周 季度
- 实现按周,月,季度,年查询统计数
- oracle 实现按周,月,季度,年查询统计数据(收集)
- javascript实现年、季度、月、时间段的查询条件切换
- oracle 实现按周,月,季度,年查询统计数据(收集)
- oracle 实现按周,月,季度,年查询统计数据
- Oracle 实现按周、月、季度、年查询统计数据
- MYSQL 查询今天,昨天,N天,本周,上周,季度,本年,上年
- Mysql 按照日、周、月、季度、年统计数据
- 2008年4月季度工作总结
- oracle年,季度,月,周,日,分组
- android-pushNotification-消息推送-学习笔记
- qt4.5.3全安装
- servlet,filter,listener
- Python-Scons-PMF脚本浅析
- 《Java优化编程》之内存管理
- mysql查询上周、月、季度、年和本周、月、季度、年
- 浏览器性能对比测试技术研究与应用
- const int *p、int * const p、int const *p
- 云存储——华为网盘
- fedora 16 service配置
- 内核链表
- C++学习小记(使用定义在其他.cpp文件中的变量或函数)
- iOS在程序中启动其他应用
- hdu 1166 线段树