当前位置:网站首页>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);
边栏推荐
- 碎片化知识管理工具Memos
- mysql econnreset_ Nodejs socket error handling error: read econnreset
- Pandora IOT development board learning (HAL Library) - Experiment 7 window watchdog experiment (learning notes)
- 阿里云SLB负载均衡产品基本概念与购买流程
- The solution of outputting 64 bits from printf format%lld of cross platform (32bit and 64bit)
- Apicloud studio3 API management and debugging tutorial
- LB10S-ASEMI整流桥LB10S
- Introduction to sap ui5 flexiblecolumnlayout control
- “百度杯”CTF比赛 九月场,Web:Upload
- Flutter draws animation effects of wave movement, curves and line graphs
猜你喜欢
ABAP editor in SAP segw transaction code
Pycharm installation third party library diagram
碎片化知识管理工具Memos
MySQL giant pit: update updates should be judged with caution by affecting the number of rows!!!
CAN和CAN FD
“百度杯”CTF比赛 九月场,Web:Upload
leetcode:221. Maximum square [essence of DP state transition]
Cf:a. the third three number problem
函数传递参数小案例
C object storage
随机推荐
Principle and configuration of RSTP protocol
jenkins安装
Introduction aux contrôles de la page dynamique SAP ui5
Discussion on error messages and API versions of SAP ui5 getsaplogonlanguage is not a function
mysql econnreset_ Nodejs socket error handling error: read econnreset
uni-app开发语音识别app,讲究的就是简单快速。
SAE international strategic investment geometry partner
Small case of function transfer parameters
ABAP editor in SAP segw transaction code
#从源头解决# 自定义头文件在VS上出现“无法打开源文件“XX.h“的问题
Introduction to sap ui5 flexiblecolumnlayout control
RHCSA9
时钟周期
一文详解ASCII码,Unicode与utf-8
《2022年中国银行业RPA供应商实力矩阵分析》研究报告正式启动
A detailed explanation of ASCII code, Unicode and UTF-8
数据泄露怎么办?'华生·K'7招消灭安全威胁
ASEMI整流桥HD06参数,HD06图片,HD06应用
Default parameters of function & multiple methods of function parameters
About the single step debugging of whether SAP ui5 floating footer is displayed or not and the benefits of using SAP ui5