当前位置:网站首页>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);
边栏推荐
- Alibaba cloud SLB load balancing product basic concept and purchase process
- 解决uni-app配置页面、tabBar无效问题
- "Baidu Cup" CTF competition in September, web:sql
- CAN和CAN FD
- [深度学习论文笔记]TransBTSV2: Wider Instead of Deeper Transformer for Medical Image Segmentation
- MySQL giant pit: update updates should be judged with caution by affecting the number of rows!!!
- A specific example of ABAP type and EDM type mapping in SAP segw transaction code
- 《2022年中国银行业RPA供应商实力矩阵分析》研究报告正式启动
- 946. 验证栈序列
- 时钟周期
猜你喜欢

碎片化知识管理工具Memos

Put functions in modules

Alibaba cloud SLB load balancing product basic concept and purchase process

无密码身份验证如何保障用户隐私安全?

Laravel document reading notes -mews/captcha use (verification code function)

初次使用腾讯云,解决只能使用webshell连接,不能使用ssh连接。

Write macro with word
![[深度学习论文笔记]UCTransNet:从transformer的通道角度重新思考U-Net中的跳跃连接](/img/b6/f9da8a36167db10c9a92dabb166c81.png)
[深度学习论文笔记]UCTransNet:从transformer的通道角度重新思考U-Net中的跳跃连接

A specific example of ABAP type and EDM type mapping in SAP segw transaction code

【服务器数据恢复】某品牌服务器存储raid5数据恢复案例
随机推荐
Talk about seven ways to realize asynchronous programming
事务的基本特性和隔离级别
Difference between avc1 and H264
[notes of in-depth study paper]uctransnet: rethink the jumping connection in u-net from the perspective of transformer channel
DataPipeline双料入选中国信通院2022数智化图谱、数据库发展报告
A specific example of ABAP type and EDM type mapping in SAP segw transaction code
go map
Asemi rectifier bridge hd06 parameters, hd06 pictures, hd06 applications
Solve Unicode decodeerror: 'GBK' codec can't decode byte 0xa2 in position 107
使用Dom4j解析XML
There is no monitoring and no operation and maintenance. The following is the commonly used script monitoring in monitoring
[daily question] 1200 Minimum absolute difference
Actual combat simulation │ JWT login authentication
Although the volume and price fall, why are the structural deposits of commercial banks favored by listed companies?
go map
数据湖(七):Iceberg概念及回顾什么是数据湖
【每日一题】1200. 最小绝对差
百度杯”CTF比赛 2017 二月场,Web:爆破-2
mysql econnreset_ Nodejs socket error handling error: read econnreset
C# 对象存储