mysql 查询当天、昨天、本周、上周、本月、上月、今年、去年数据
mysql查询今天、昨天、7天、近30天、本月、上一月 数据
今天
select * from 表名 where to_days(时间字段名) = to_days(now());
昨天
SELECT * FROM 表名 WHERE TO_DAYS( NOW( ) ) - TO_DAYS( 时间字段名) = 1
近7天
SELECT * FROM 表名 where DATE_SUB(CURDATE(), INTERVAL 7 DAY) <= date(时间字段名)
查询当前这周的数据
SELECT name,submittime FROM enterprise WHERE YEARWEEK(date_format(submittime,'%Y-%m-%d')) = YEARWEEK(now());
查询上周的数据
SELECT name,submittime FROM enterprise WHERE YEARWEEK(date_format(submittime,'%Y-%m-%d')) = YEARWEEK(now())-1;
近30天
SELECT * FROM 表名 where DATE_SUB(CURDATE(), INTERVAL 30 DAY) <= date(时间字段名)
本月
SELECT * FROM 表名 WHERE DATE_FORMAT( 时间字段名, '%Y%m' ) = DATE_FORMAT( CURDATE( ) , '%Y%m' )
上一月
SELECT * FROM 表名 WHERE PERIOD_DIFF( date_format( now( ) , '%Y%m' ) , date_format( 时间字段名, '%Y%m' ) ) =1
查询距离当前现在6个月的数据
select name,submittime from enterprise where submittime between date_sub(now(),interval 6 month) and 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 查询当天、本周,本月,上一个月的数据---https://www.cnblogs.com/benefitworld/p/5832897.html
mysql 查询当天.本周,本月,上一个月的数据 今天 select * from 表名 where to_days(时间字段名) = to_days(now()); 昨天 SELECT * FROM ...
- MySQL 查询当天、本周,本月、上一个月的数据
mysql查询当天的所有信息: SELECT * FROM 表名 WHERE year(时间字段名)=year(now()) and month(时间字段名) = month(now()) and d ...
- mysql 查询当天、本周,本月,上一个月的数据
今天 select * from 表名 where to_days(时间字段名) = to_days(now()); 昨天 近7天 DAY) <= date(时间字段名) 近30天 DAY) & ...
- mysql查询当天,本周,本月,上一个月的数据(转)
今天 select * from 表名 where to_days(时间字段名) = to_days(now()); 昨天 SELECT * FROM 表名 WHERE TO_DAYS( NOW( ) ...
- 关于 MySQL查询当天、本周,本月,上一个月的数据
今天 select * from 表名 where to_days(时间字段名) = to_days(now()); 昨天 SELECT * FROM 表名 WHERE TO_DAYS( NOW( ) ...
- MySql查询当天、本周、本月、本季度、本年的数据
1.今天 SELECT * FROM 表名 WHERE TO_DAYS(时间字段名) = TO_DAYS(NOW()); 2.昨天 ; 3.本周 SELECT * FROM 表名 WHERE YEAR ...
- MySQL查询当天、本周、本月数据语句
今天 select * from 表名 where to_days(时间字段名) = to_days(now()); 昨天 SELECT * FROM 表名 WHERE TO_DAYS( NOW( ) ...
- JS 时间 获取 当天,昨日,本周,上周,本月,上月
调用 setTimeRange (2); function setTimeRange (v) { var fmt = 'YYYY-MM-DD HH:mm'; var now = new Date() ...
- MySQL查询当天、本周,本月,上一个月的数据
QUARTER)); ; MONTH),'%Y-%m') select * from user where DATE_FORMAT(pudate,'%Y%m') = DATE_FORMAT(CURDA ...
- mySql 查询当天、本周、最近7天、本月、最近30天的语句
mySql 查询当天.本周.最近7天.本月.最近30天的语句 原创 2017年04月13日 16:40:38 标签: 962 编辑 删除 -- 当天 SELECT * FROM 表名 WHERE w ...
随机推荐
- Redis源码解析:20sentinel(一)初始化、建链
sentinel(哨兵)是redis的高可用解决方案.由一个或多个sentinel实例组成的分布式系统,可以监控任意多个主节点,以及它们属下的所有从节点.当某个主节点下线时,sentinel可以将下线 ...
- TZ_05_Spring_基于AOP的xml配置
1.分析 1>首先我们有一个Service需要增强 将Service增加一个日志(Logger) 2>写了一个日志的通知并且它可以对Service进行日志增强 ...
- Hackerrank--XOR love (Math系列)
题目链接 Devendra loves the XOR operation very much which is denoted by ∧ sign in most of the programmin ...
- win8 装的SQL Server2012 企业版
链接:ed2k://|file|cn_sql_server_2012_enterprise_edition_x86_x64_dvd_813295.iso|5054384128|BC78EFDC4005 ...
- springmvc配置不拦截静态资源
<mvc:resources mapping="/js/**" location="/js/"/>
- 【Django入坑之路】Models操作
1:字段 AutoField(Field) - int自增列,必须填入参数 primary_key=True BigAutoField(AutoField) - bigint自增列,必须填入参数 pr ...
- PyCharm常用技巧集合
PyCharm常用技巧集合 一.添加或者修改文件模板 File>settings>Editor>File and Code Templates>Python Script 你可 ...
- python实例 字典
#! /usr/bin/python x={'a':'aaa','b':'bbb','c':12} print (x['a']) print (x['b']) print (x['c']) for k ...
- 【Ruby】与ruby相关的内容
本博文是为了记录Ruby相关的可学习资源,以便日常使用 在线学习Rails的网站版本 Ruby on Rails教程(Rails 5) Ruby的中文社区 Ruby China
- eclipse修改中文注释的字体(亲测有用!)
Window –> Preferences –> General –> Appearance –> Colors and Fonts –> Basic –> Tex ...