当前位置:网站首页>MySQL get time
MySQL get time
2022-07-05 13:23:00 【Exquisite·】
# The first day of that year :
SELECT DATE_SUB(CURDATE(),INTERVAL dayofyear(now())-1 DAY);
# The last day of the year :
SELECT concat(YEAR(now()),'-12-31');
# At present week The first day of :
select date_sub(curdate(),INTERVAL WEEKDAY(curdate()) + 1 DAY);
# At present week Last day :
select date_sub(curdate(),INTERVAL WEEKDAY(curdate()) - 5 DAY);
# Previous one week The first day of :
select date_sub(curdate(),INTERVAL WEEKDAY(curdate()) + 8 DAY);
# Previous one week Last day :
select date_sub(curdate(),INTERVAL WEEKDAY(curdate()) + 2 DAY);
# The first two week The first day of :
select date_sub(curdate(),INTERVAL WEEKDAY(curdate()) + 15 DAY);
# The first two week Last day :
select date_sub(curdate(),INTERVAL WEEKDAY(curdate()) + 9 DAY);
# At present month The first day of :
SELECT concat(date_format(LAST_DAY(now()),'%Y-%m-'),'01');
# At present month Last day :
SELECT LAST_DAY(now());
# Previous one month The first day of :
SELECT concat(date_format(LAST_DAY(now() - interval 1 month),'%Y-%m-'),'01');
# Previous one month Last day :
SELECT LAST_DAY(now() - interval 1 month);
# The first two month The first day of :
SELECT concat(date_format(LAST_DAY(now() - interval 2 month),'%Y-%m-'),'01');
# The first two month Last day :
SELECT LAST_DAY(now() - interval 2 month);
# At present quarter The first day of :
select concat(date_format(LAST_DAY(MAKEDATE(EXTRACT(YEAR FROM CURDATE()),1) + interval QUARTER(CURDATE())*3-3 month),'%Y-%m-'),'01');
# At present quarter Last day :
select LAST_DAY(MAKEDATE(EXTRACT(YEAR FROM CURDATE()),1) + interval QUARTER(CURDATE())*3-1 month);
# Previous one quarter The first day of :
select concat(date_format(LAST_DAY(MAKEDATE(EXTRACT(YEAR FROM CURDATE()),1) + interval QUARTER(CURDATE())*3-6 month),'%Y-%m-'),'01');
# Previous one quarter Last day :
select LAST_DAY(MAKEDATE(EXTRACT(YEAR FROM CURDATE()),1) + interval QUARTER(CURDATE())*3-4 month);
# The first two quarter The first day of :
select concat(date_format(LAST_DAY(MAKEDATE(EXTRACT(YEAR FROM CURDATE()),1) + interval QUARTER(CURDATE())*3-9 month),'%Y-%m-'),'01');
# The first two quarter Last day :
select LAST_DAY(MAKEDATE(EXTRACT(YEAR FROM CURDATE()),1) + interval QUARTER(CURDATE())*3-7 month);
边栏推荐
- 记录一下在深度学习-一些bug处理
- TortoiseSVN使用情形、安装与使用
- 【MySQL 使用秘籍】一网打尽 MySQL 时间和日期类型与相关操作函数(三)
- 山东大学暑期实训一20220620
- 同事半个月都没搞懂selenium,我半个小时就给他整明白!顺手秀了一波爬淘宝的操作[通俗易懂]
- RHCSA8
- Could not set property ‘id‘ of ‘class XX‘ with value ‘XX‘ argument type mismatch 解决办法
- 关于 Notion-Like 工具的反思和畅想
- 多人合作项目查看每个人写了多少行代码
- Sorry, we can't open xxxxx Docx, because there is a problem with the content (repackaging problem)
猜你喜欢
The Research Report "2022 RPA supplier strength matrix analysis of China's banking industry" was officially launched
“百度杯”CTF比赛 九月场,Web:SQL
MSTP and eth trunk
C# 对象存储
Could not set property ‘id‘ of ‘class XX‘ with value ‘XX‘ argument type mismatch 解决办法
“百度杯”CTF比赛 九月场,Web:Upload
Binder通信过程及ServiceManager创建过程
RHCSA10
Shandong University Summer Training - 20220620
Alibaba cloud SLB load balancing product basic concept and purchase process
随机推荐
Cloudcompare - point cloud slice
RHCSA9
UnicodeDecodeError: ‘utf-8‘ codec can‘t decode byte 0xe6 in position 76131: invalid continuation byt
Hundred days to complete the open source task of the domestic database opengauss -- openguass minimalist version 3.0.0 installation tutorial
Hiengine: comparable to the local cloud native memory database engine
Alibaba cloud SLB load balancing product basic concept and purchase process
Reverse Polish notation
How to choose note taking software? Comparison and evaluation of notion, flowus and WOLAI
Clock cycle
Idea设置方法注释和类注释
"Baidu Cup" CTF competition in September, web:upload
聊聊异步编程的 7 种实现方式
MATLAB论文图表标准格式输出(干货)
go 字符串操作
Detailed explanation of navigation component of openharmony application development
Navigation property and entityset usage in SAP segw transaction code
RHCSA8
“百度杯”CTF比赛 九月场,Web:Upload
How to realize batch sending when fishing
Le rapport de recherche sur l'analyse matricielle de la Force des fournisseurs de RPA dans le secteur bancaire chinois en 2022 a été officiellement lancé.