当前位置:网站首页>MySQL queries the data of today, yesterday, this week, last week, this month, last month, this quarter, last quarter, this year, last year
MySQL queries the data of today, yesterday, this week, last week, this month, last month, this quarter, last quarter, this year, last year
2022-06-29 02:23:00 【xiao pan】
today
select * from Table name where to_days( Time field name ) = to_days(now())yesterday
select * from Table name where to_days( now( ) ) - to_days( Time field name ) <= 1near 7 God
select * from Table name where date_sub(curdate(), interval 7 day) <= date( Time field name )Current week
select name,submittime from enterprise where yearweek(date_format(submittime,'%y-%m-%d')) = yearweek(now())Last week,
select name,submittime from enterprise where yearweek(date_format(submittime,'%y-%m-%d')) = yearweek(now())-1near 30 God
select * from Table name where date_sub(curdate(), interval 30 day) <= date( Time field name )This month,
select * from Table name where date_format( Time field name , '%y%m' ) = date_format( curdate( ) , '%y%m' )Last month
select * from Table name where period_diff( date_format( now( ) , '%y%m' ) , date_format( Time field name , '%y%m' ) ) =1Query the data of the current half year
select name,submittime from enterprise where submittime between date_sub(now(),interval 6 month) and now()
This quarter
select * from `ht_invoice_information` where quarter(create_date)=quarter(now())Last quarter
select * from `ht_invoice_information` where quarter(create_date)=quarter(date_sub(now(),interval 1 quarter))This year
select * from `ht_invoice_information` where year(create_date)=year(now())Last year
select * from `ht_invoice_information` where year(create_date)=year(date_sub(now(),interval 1 year))
边栏推荐
- Written examination questions, answers and analysis of Digital IC design and FPGA design (2) 2021 Huawei Hisilicon (Part 1)
- What is the dry goods microservice architecture? What are the advantages and disadvantages?
- What is Mipi
- Finally got the byte offer. The 25-year-old inexperienced experience in software testing is written to you who are still confused
- 大三下期末考試
- Talk about the copyonwritearraylist of JUC
- 东方财富股票开户是会有什么风险吗?东方财富开户安全吗
- 微信运动自动点赞
- Ctfhub web password weak password
- Why install an SSL certificate on a web site?
猜你喜欢
![[redis] get to know redis for the first time](/img/02/3c6a7f6ea8c563386a4cd458024728.png)
[redis] get to know redis for the first time

Trigonometric function calculation
![[redis] set type](/img/97/0a83016e89316849c01072044f2124.png)
[redis] set type

【Redis】Key的层级结构

CTFHub-Web-密码口令-弱口令

The 10 most commonly used gadgets for waterfall project management can be built and used freely

Mipi d-phy -- contents of HS and LP agreements

OpenResty 使用介绍

【Redis】SortedSet类型

基于 RISC-V SoC 的可配置 FFT 系统设计(1)引言
随机推荐
QT basics tutorial: data types and containers
Studies of relative costs for development in different languages
Is there any risk in opening an account for Dongfang fortune stock? Is it safe for Dongfang fortune to open an account
Cross border information station
对补wasm环境的一些测试
Smart world 2030
大三下期末考試
Interviewer: with the for loop, why do you need foreach??
Talk about the copyonwritearraylist of JUC
Eliminate the hover effect when the button is disabled
What is the dry goods microservice architecture? What are the advantages and disadvantages?
[redis] get to know redis for the first time
Finally got the byte offer. The 25-year-old inexperienced experience in software testing is written to you who are still confused
【学习笔记】子集和问题
Dialogue with opensea co creation Alex: we still only touch the tip of the iceberg of NFT capability | chain catcher
Digital IC design, FPGA design written examination questions, answers and analysis of autumn move (1) 2022 Ziguang zhanrui (Part 1)
MySQL详解 --- 聚合与分组
基于 RISC-V SoC 的可配置 FFT 系统设计(1)引言
Understanding and design of high concurrency
Query any field of any table in JPA to the util method of entity class dto