当前位置:网站首页>Common MySQL date query
Common MySQL date query
2022-06-12 04:37:00 【Wh 789】
In this article, common MYSQL Date query
List of articles
Commonly used MYSQL Date query
MYSQL Query today 、 yesterday 、 This week, 、 This month, 、 Last month 、 Next month 、 The previous year 、 Next year 、 Last quarter 、 Next quarter
-- 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 ) <= 1;
-- This week,
select * from Table name where yearweek( date_format( Time field name ,'%y-%m-%d' ) ) = yearweek(now());
-- Last week
select * from Table name where yearweek(date_format( Time field name , '%y-%m-%d')) = yearweek(now())-1;
-- This month,
select * from Table name where date_format( Time field name ,'%y-%m')=date_format(now(),'%y-%m');
-- Last month
select * from Table name where period_diff(date_format(now(), '%y%m'), date_format( Time field name , '%y%m')) = 1;
-- This quarter
select * from Table name where quarter( Time field name )=quarter(now());
-- the previous quarter
select * from Table name where quarter( Time field name )=quarter(date_sub(now(),interval 1 quarter));
-- This year
select * from Table name where year( Time field name )=year(now());
-- The previous year
select * from Table name where year( Time field name )=year(date_sub(now(),interval 1 year));
-- Query distance now 6 Months of data
select * from Table name where Time field name between date_sub(now(),interval 6 month) and now();
-- Zhou Date data
-- Get yesterday's date
select DATE_SUB( curdate( ), INTERVAL 1 DAY );
边栏推荐
- 疫情数据分析平台工作报告【6】可视化绘图
- D1 哪吒开发板 上电记录
- Labor
- Oracle paging query ~~rownum (line number)
- PostgreSQL age XID maintenance prevents the database from being read-only
- 智能面板WiFi聯動技術,ESP32無線芯片模組,物聯網WiFi通信應用
- [issue 31] 360 background development practice experience - two rounds of technical aspects
- 2022 examination questions and online simulation examination for safety management personnel of hazardous chemical business units
- LabVIEW关于TDMS和Binary存储速度
- 树莓派4B使用Intel Movidius NCS 2来进行推断加速
猜你喜欢

路灯照明物联网技术方案,ESP32-S3芯片通信应用,智能WiFi远程控制
![Work report of epidemic data analysis platform [6] visual drawing](/img/cc/9eaff451068d0efb174b58719c700e.png)
Work report of epidemic data analysis platform [6] visual drawing

MySQL master-slave construction and Django implementation of read-write separation

Recommended system cleaning tools, cocktail Download

JWT學習與使用

SQL注入上传一句话木马(转)

智能面板WiFi聯動技術,ESP32無線芯片模組,物聯網WiFi通信應用
![Work report on epidemic data analysis platform [7] Alibaba cloud related](/img/e2/acc79256f8f90ca730c39ffb941dab.png)
Work report on epidemic data analysis platform [7] Alibaba cloud related

L1-064 AI core code valued at 100 million (20 points)

Raspberry pie 4B uses Intel movidius NCS 2 for inference acceleration
随机推荐
Enterprise Architect v16
Oracle's instr()
C# TaskFactory. Startnew method
C# Task. Waitall method
Recommended system cleaning tools, cocktail Download
Question for the 3D printing lattice?
SQL injection upload one sentence Trojan horse (turn)
Install pycharm under Kali and create a shortcut access
Smart Panel wifi Linkage Technology, esp32 wireless chip module, Internet of Things WiFi Communication Application
Memory protection
How Windows installs multiple versions of MySQL and starts it at the same time
[wechat applet] the mobile terminal selects and publishes pictures
Please calculate the value of the following function recursively: PX (x, n) =x-x^2 +x^3- x^4+... (-1) n-1) (xn) n > 0 * * input format requirements: "%lf%d" prompt: "enter X and n:"
千字巨著《编程后传》
Kinematic gauge (14) - Triangle optimal path problem
2022 low voltage electrician test questions and simulation test
无线物联网WiFi模块方案,ESP32-S3芯片技术,助力设备智能化
The third "World War" - chip defense, smokeless battlefield!
Solid programming concepts
mysqld: Can‘t create directory ‘D: oftinstall\mysql57 (Errcode: 2 - No such file or directory)