澳门新萄京及不分析,MySQL查询前天
分类:数据库

<if test="type ==1">
and DATE_FORMAT(create_date,'%Y-%m-%d') = DATE_FORMAT(now(),'%Y-%m-%d')
</if>
<if test="type ==2">

今天

mysql中询问明日,前不久,这两日sql语句

www.111cn.net 编辑:netuser 来源:转载

本文章给各位同学介绍mysql中查询前日,前几日,上个月sql语句,有亟待了然的朋友可仿效。

今天 select * from 表名 where to_days(时间字段名) = to_days(now());

昨天Select * FROM 表名 Where TO_DAYS( NOW( ) ) - TO_DAYS( 时间字段名) <= 1

7天Select * FROM 表名 where DATE_SUB(CUTucsonDATE(), INTE冠道VAL 7 DAY) <= date(时间字段名)

近30天Select * FROM 表名 where DATE_SUB(CUGL450DATE(), INTE大切诺基VAL 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

#澳门新萄京及不分析,MySQL查询前天。询问上一季度数据
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`澳门新萄京及不分析,MySQL查询前天。 where year(create_date)=year(date_sub(now(),interval 1 year));

 

查询当前上周的数据 
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;

询问当前月份的数据
select name,submittime from enterprise   where date_format(submittime,'%Y-%m')=date_format(now(),'%Y-%m')

询问间距当前现行反革命7个月的多少
select name,submittime from enterprise where submittime between date_sub(now(),interval 6 month) and now();

询问下一个月的数量
select name,submittime from enterprise   where date_format(submittime,'%Y-%m')=date_format(DATE_SUB(curdate(), INTERVAL 1 MONTH),'%Y-%m')

select * from ` user ` where DATE_FORMAT(pudate, ' %Y%m ' ) = DATE_FORMAT(CURDATE(), ' %Y%m ' ) ;

select * from user where WEEKOFYEAR(FROM_UNIXTIME(pudate,'%y-%m-%d')) = WEEKOFYEAR(now())

select * 
from user 
where MONTH (FROM_UNIXTIME(pudate, ' %y-%m-%d ' )) = MONTH (now())

select * 
from [ user ] 
where YEAR (FROM_UNIXTIME(pudate, ' %y-%m-%d ' )) = YEAR (now())
and MONTH (FROM_UNIXTIME(pudate, ' %y-%m-%d ' )) = MONTH (now())

select * 
from [ user ] 
where pudate between 下二个月最后一天
and 后一个月底后天

where   date(regdate)   =   curdate();

select   *   from   test   where   year(regdate)=year(now())   and   month(regdate)=month(now())   and   day(regdate)=day(now())

SELECT date( c_instime ) ,curdate( )
FROM `t_score`
WHERE 1
LIMIT 0 , 30

<![CDATA[
and DATE_FORMAT(create_date,'%Y-%m-%d') >= DATE_FORMAT(#{minDate},'%Y-%m-%d')
and DATE_FORMAT(create_date,'%Y-%m-%d') <= DATE_FORMAT(#{maxDate},'%Y-%m-%d')
]]>
</if>
<if test="type ==3">
and DATE_FORMAT(create_date,'%Y-%m') = DATE_FORMAT(CURDATE(),'%Y-%m')
</if>

select * from 表名 where to_days(时间字段名) = to_days(now());

 

昨天

orcal的时光相比较

SELECT * FROM 表名 WHERE TO_DAYS( NOW( ) ) - TO_DAYS( 时间字段名) <= 1

select * from RegulatoryRecord where  regulatorydate < to_date('2018-08-15 15:58:00','yyyy-mm-dd hh24:mi:ss')

7天

SELECT * FROM 表名 where DATE_SUB(CU中华VDATE(), INTEXC60VAL 7 DAY) <= date(时间字段名)

近30天

SELECT * FROM 表名 where DATE_SUB(CUENCOREDATE(), INTEPRADOVAL 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

#查询上年数据

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 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;

查询当前月份的数据

select name,submittime from enterprise   where date_format(submittime,'%Y-%m')=date_format(now(),'%Y-%m')

查询间距当前现行反革命6个月的数额

select name,submittime from enterprise where submittime between date_sub(now(),interval 6 month) and now();

查询过意气风发阵子的数量

select name,submittime from enterprise   where date_format(submittime,'%Y-%m')=date_format(DATE_SUB(curdate(), INTERVAL 1 MONTH),'%Y-%m')

select*from`user`whereDATE_FORMAT(pudate,'%Y%m')=DATE_FORMAT(CURDATE(),'%Y%m') ;

select * from user where WEEKOFYEAR(FROM_UNIXTIME(pudate,'%y-%m-%d')) = WEEKOFYEAR(now())

select*

from user

where MONTH (FROM_UNIXTIME(pudate, ' %y-%m-%d ' ))=MONTH (now())

select*

from [ user ]

where YEAR (FROM_UNIXTIME(pudate, ' %y-%m-%d ' ))=YEAR (now())

andMONTH (FROM_UNIXTIME(pudate, ' %y-%m-%d ' ))=MONTH (now())

select*

from [ user ]

where pudatebetween前段日子最后一天

and下月第一天

where   date(regdate)   =   curdate();

select   *   from   test   where   year(regdate)=year(now())   and   month(regdate)=month(now())   and   day(regdate)=day(now())

SELECT date( c_instime ) ,curdate( )

FROM `t_score`

WHERE 1

LIMIT 0 , 30

本文由澳门新萄京发布于数据库,转载请注明出处:澳门新萄京及不分析,MySQL查询前天

上一篇:没有了 下一篇:没有了
猜你喜欢
热门排行
精彩图文
  • 目录维护常用方法总括,SQLSEEscortVE宝马7系怎么着
    目录维护常用方法总括,SQLSEEscortVE宝马7系怎么着
    意气风发. 索引概述 关于介绍索引,有豆蔻梢头种“文章太史,挥毫万字,一饮千钟”的豪迈感觉,因为索引须求讲的知识点太多。在每一种关系型数据
  • 澳门新萄京采用的恢复方法
    澳门新萄京采用的恢复方法
    set rowcount 20000 delete from UFSystem..ua_log set rowcount 0 原文地址: truncate 表之后,采用的恢复方法 作者: ban仙 一、sybase创建用户数据库的脚本。 设置  trunca
  • Mysql数据库备份工具,逻辑备份
    Mysql数据库备份工具,逻辑备份
          几天前收到某个业务项目,MySQL数据库逻辑备份mysqldump备份失败的邮件,本是在休假,但本着工作认真负责,7*24小时不间断运维的高尚职业情操,开
  • 澳门新萄京:创建数据库邮件,数据库邮件
    澳门新萄京:创建数据库邮件,数据库邮件
      本文转自: 原文: SQL Server数据库邮件使用 SMTP服务器转发邮件,允许用户配置数据库邮件,并通过存储过程 msdb.dbo.sp_send_dbmail 向特定的用户发送邮件,
  • 澳门新萄京:Consul初体验
    澳门新萄京:Consul初体验
      Preface       Today I'm gonna implement a consul inmy environment to discover service of MySQL database and check whetherthe master-slave is working normally.   Introduce       Consul is a to