当前位置:网站首页>mysql获得时间
mysql获得时间
2022-07-05 13:17:00 【玲珑·】
#当年第一天:
SELECT DATE_SUB(CURDATE(),INTERVAL dayofyear(now())-1 DAY);
#当年最后一天:
SELECT concat(YEAR(now()),'-12-31');
#当前week的第一天:
select date_sub(curdate(),INTERVAL WEEKDAY(curdate()) + 1 DAY);
#当前week的最后一天:
select date_sub(curdate(),INTERVAL WEEKDAY(curdate()) - 5 DAY);
#前一week的第一天:
select date_sub(curdate(),INTERVAL WEEKDAY(curdate()) + 8 DAY);
#前一week的最后一天:
select date_sub(curdate(),INTERVAL WEEKDAY(curdate()) + 2 DAY);
#前两week的第一天:
select date_sub(curdate(),INTERVAL WEEKDAY(curdate()) + 15 DAY);
#前两week的最后一天:
select date_sub(curdate(),INTERVAL WEEKDAY(curdate()) + 9 DAY);
#当前month的第一天:
SELECT concat(date_format(LAST_DAY(now()),'%Y-%m-'),'01');
#当前month的最后一天:
SELECT LAST_DAY(now());
#前一month的第一天:
SELECT concat(date_format(LAST_DAY(now() - interval 1 month),'%Y-%m-'),'01');
#前一month的最后一天:
SELECT LAST_DAY(now() - interval 1 month);
#前两month的第一天:
SELECT concat(date_format(LAST_DAY(now() - interval 2 month),'%Y-%m-'),'01');
#前两month的最后一天:
SELECT LAST_DAY(now() - interval 2 month);
#当前quarter的第一天:
select concat(date_format(LAST_DAY(MAKEDATE(EXTRACT(YEAR FROM CURDATE()),1) + interval QUARTER(CURDATE())*3-3 month),'%Y-%m-'),'01');
#当前quarter的最后一天:
select LAST_DAY(MAKEDATE(EXTRACT(YEAR FROM CURDATE()),1) + interval QUARTER(CURDATE())*3-1 month);
#前一quarter的第一天:
select concat(date_format(LAST_DAY(MAKEDATE(EXTRACT(YEAR FROM CURDATE()),1) + interval QUARTER(CURDATE())*3-6 month),'%Y-%m-'),'01');
#前一quarter的最后一天:
select LAST_DAY(MAKEDATE(EXTRACT(YEAR FROM CURDATE()),1) + interval QUARTER(CURDATE())*3-4 month);
#前两quarter的第一天:
select concat(date_format(LAST_DAY(MAKEDATE(EXTRACT(YEAR FROM CURDATE()),1) + interval QUARTER(CURDATE())*3-9 month),'%Y-%m-'),'01');
#前两quarter的最后一天:
select LAST_DAY(MAKEDATE(EXTRACT(YEAR FROM CURDATE()),1) + interval QUARTER(CURDATE())*3-7 month);
边栏推荐
- 个人组件 - 消息提示
- Difference between avc1 and H264
- Concurrent performance test of SAP Spartacus with JMeter
- APICloud Studio3 WiFi真机同步和WiFi真机预览使用说明
- The solution of outputting 64 bits from printf format%lld of cross platform (32bit and 64bit)
- [深度学习论文笔记]TransBTSV2: Wider Instead of Deeper Transformer for Medical Image Segmentation
- 使用Dom4j解析XML
- RHCSA8
- 从外卖点单浅谈伪需求
- Go array and slice
猜你喜欢
Reverse Polish notation
It's too convenient. You can complete the code release and approval by nailing it!
蜀天梦图×微言科技丨达梦图数据库朋友圈+1
"Baidu Cup" CTF competition in September, web:sql
量价虽降,商业银行结构性存款为何受上市公司所偏爱?
潘多拉 IOT 开发板学习(HAL 库)—— 实验7 窗口看门狗实验(学习笔记)
Concurrent performance test of SAP Spartacus with JMeter
FPGA 学习笔记:Vivado 2019.1 添加 IP MicroBlaze
[daily question] 1200 Minimum absolute difference
How to realize batch sending when fishing
随机推荐
MySQL giant pit: update updates should be judged with caution by affecting the number of rows!!!
今年上半年,通信行业发生了哪些事?
Clock cycle
碎片化知识管理工具Memos
【Hot100】33. 搜索旋转排序数组
[深度学习论文笔记]TransBTSV2: Wider Instead of Deeper Transformer for Medical Image Segmentation
Introduction to sap ui5 dynamicpage control
Rocky basic command 3
#yyds干货盘点# 解决名企真题:搬圆桌
A detailed explanation of ASCII code, Unicode and UTF-8
LB10S-ASEMI整流桥LB10S
[深度学习论文笔记]UCTransNet:从transformer的通道角度重新思考U-Net中的跳跃连接
jenkins安装
uni-app开发语音识别app,讲究的就是简单快速。
Although the volume and price fall, why are the structural deposits of commercial banks favored by listed companies?
A specific example of ABAP type and EDM type mapping in SAP segw transaction code
Pandora IOT development board learning (HAL Library) - Experiment 7 window watchdog experiment (learning notes)
My colleague didn't understand selenium for half a month, so I figured it out for him in half an hour! Easily showed a wave of operations of climbing Taobao [easy to understand]
APICloud Studio3 WiFi真机同步和WiFi真机预览使用说明
go 数组与切片