当前位置:网站首页>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);
边栏推荐
- 【Hot100】34. Find the first and last positions of elements in a sorted array
- MySQL --- 数据库查询 - 排序查询、分页查询
- ABAP editor in SAP segw transaction code
- #从源头解决# 自定义头文件在VS上出现“无法打开源文件“XX.h“的问题
- Android本地Sqlite数据库的备份和还原
- Realize the addition of all numbers between 1 and number
- 精彩速递|腾讯云数据库6月刊
- 【Hot100】34. 在排序数组中查找元素的第一个和最后一个位置
- js判断数组中是否存在某个元素(四种方法)
- Overflow toolbar control in SAP ui5 view
猜你喜欢

Solve Unicode decodeerror: 'GBK' codec can't decode byte 0xa2 in position 107
![leetcode:221. Maximum square [essence of DP state transition]](/img/ea/158e8659657984794c52a0449e0ee5.png)
leetcode:221. Maximum square [essence of DP state transition]

蜀天梦图×微言科技丨达梦图数据库朋友圈+1

逆波兰表达式

Talk about seven ways to realize asynchronous programming

函数传递参数小案例

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

《2022年中國銀行業RPA供應商實力矩陣分析》研究報告正式啟動

RHCSA9

Android本地Sqlite数据库的备份和还原
随机推荐
How to choose note taking software? Comparison and evaluation of notion, flowus and WOLAI
【Hot100】33. 搜索旋转排序数组
【每日一题】1200. 最小绝对差
【Hot100】34. 在排序数组中查找元素的第一个和最后一个位置
SAE international strategic investment geometry partner
先写API文档还是先写代码?
函数的默认参数&函数参数的多种方法
同事半个月都没搞懂selenium,我半个小时就给他整明白!顺手秀了一波爬淘宝的操作[通俗易懂]
There is no monitoring and no operation and maintenance. The following is the commonly used script monitoring in monitoring
程序员成长第八篇:做好测试工作
Flutter draws animation effects of wave movement, curves and line graphs
Put functions in modules
初次使用腾讯云,解决只能使用webshell连接,不能使用ssh连接。
Clock cycle
RHCSA10
使用Dom4j解析XML
A specific example of ABAP type and EDM type mapping in SAP segw transaction code
LB10S-ASEMI整流桥LB10S
ABAP editor in SAP segw transaction code
A detailed explanation of ASCII code, Unicode and UTF-8