当前位置:网站首页>Get the first/last day of the current week, month, quarter in MySQL
Get the first/last day of the current week, month, quarter in MySQL
2022-08-03 03:04:00 【Oranges are not oranges】
mysql 获取当年第一天的年月日格式:
SELECT DATE_SUB(CURDATE(),INTERVAL dayofyear(now())-1 DAY);
MySQLto get the current week、月、first day of the season/最后一天
The first day of the current week:
select date_sub(curdate(),INTERVAL WEEKDAY(curdate()) + 1 DAY)
The last day of the current week:
select date_sub(curdate(),INTERVAL WEEKDAY(curdate()) – 5 DAY)
The first day of the previous week:
select date_sub(curdate(),INTERVAL WEEKDAY(curdate()) + 8 DAY)
前一周的最后一天:
select date_sub(curdate(),INTERVAL WEEKDAY(curdate()) + 2 DAY)
The first day of the first two weeks:
select date_sub(curdate(),INTERVAL WEEKDAY(curdate()) + 15 DAY)
The last day of the first two weeks:
select date_sub(curdate(),INTERVAL WEEKDAY(curdate()) + 9 DAY)
当前月的第一天:
SELECT concat(date_format(LAST_DAY(now()),’%Y-%m-’),’01′)
当前月的最后一天:
SELECT LAST_DAY(now())
The first day of the previous month:
SELECT concat(date_format(LAST_DAY(now() – interval 1 month),’%Y-%m-’),’01′)
The last day of the previous month:
SELECT LAST_DAY(now() – interval 1 month)
The first day of the first two months:
SELECT concat(date_format(LAST_DAY(now() – interval 2 month),’%Y-%m-’),’01′)
The last day of the first two months:
SELECT LAST_DAY(now() – interval 2 month)
The first day of the current season:
select concat(date_format(LAST_DAY(MAKEDATE(EXTRACT(YEAR FROM CURDATE()),1) + interval QUARTER(CURDATE())*3-3 month),’%Y-%m-’),’01′)
The last day of the current season:
select LAST_DAY(MAKEDATE(EXTRACT(YEAR FROM CURDATE()),1) + interval QUARTER(CURDATE())*3-1 month)
The first day of the previous season:
select concat(date_format(LAST_DAY(MAKEDATE(EXTRACT(YEAR FROM CURDATE()),1) + interval QUARTER(CURDATE())*3-6 month),’%Y-%m-’),’01′)
The last day of the previous season:
select LAST_DAY(MAKEDATE(EXTRACT(YEAR FROM CURDATE()),1) + interval QUARTER(CURDATE())*3-4 month)
The first day of the first two seasons:
select concat(date_format(LAST_DAY(MAKEDATE(EXTRACT(YEAR FROM CURDATE()),1) + interval QUARTER(CURDATE())*3-9 month),’%Y-%m-’),’01′)
The last day of the first two seasons:
select LAST_DAY(MAKEDATE(EXTRACT(YEAR FROM CURDATE()),1) + interval QUARTER(CURDATE())*3-7 month)
边栏推荐
- 9-WebUtil工具类.md
- 45部署LVS-DR群集
- [QNX Hypervisor 2.2用户手册]10 虚拟设备参考
- 孩子坐不住就是不专注?猿辅导揭秘专注力的三大误区
- 【UE4】搭建局域网内VR直播 UE4.27
- 【Objective-C语言中的@property增强】
- 12-security退出.md
- 2022-08-02:小红拿到了一个大立方体,该大立方体由1*1*1的小方块拼成,初始每个小方块都是白色。 小红可以每次选择一个小方块染成红色, 每次小红可能选择同一个小方块重复染色, 每次染色以后,
- VS2010 组件列表与对应名称
- Wei Dongshan Digital Photo Frame Project Learning (5) Transplantation of libjpeg-turbo
猜你喜欢
随机推荐
如何准备考pmp?
PHICOMM(斐讯)N1盒子 - Armbian5.77(Debian 9)配置自动连接WIFI无线网络
公司代码学习笔记
sql注入是什么意思以及防止sql注入?
豆瓣评分9.3的好书,文末给大家抽奖送几本!
复杂多层布局的初级智能文本提示器
”QSqlDatabasePrivate::removeDatabase: connection ‘test-connect‘ is still in use“数据库多次打开报错
XSS攻击
一些面试的总结
Introduction to agile development
常用工具链和虚拟环境-Cygwin
部门之间,互不信任正常吗?(你是否遇到过)
一个循环,两个循环问题的思考及复现
项目管理到底管的是什么?
不想当Window的Dialog不是一个好Modal,弹窗翻身记...
怎么做postgrsql主备?
有趣简单的M2处理器性能实验:Swift与C代码执行速度的比较
大厂标配 | 百亿级并发系统设计 | 学完薪资框框涨
软件定义网络实验之SDN网络简单管理及开发
10-security登录