SELECT
SUBSTR(FROM_UNIXTIME(UNIX_TIMESTAMP()),1,10) ,--out 2021-09-08 执行代码日期,当日日期
concat(SUBSTR(DATE_SUB(FROM_UNIXTIME(UNIX_TIMESTAMP()),DAY(FROM_UNIXTIME(UNIX_TIMESTAMP()))),1,7) ,'-01'), --out 2021-08-01 上月月初
DATE_SUB(FROM_UNIXTIME(UNIX_TIMESTAMP()),DAY(FROM_UNIXTIME(UNIX_TIMESTAMP()))), --out 2021-08-31 上月月未
date_sub(SUBSTR(FROM_UNIXTIME(UNIX_TIMESTAMP()),1,10),pmod(datediff(SUBSTR(FROM_UNIXTIME(UNIX_TIMESTAMP()),1,10),'1900-01-08'),7)+7), --out 2021-08-30 上周周一
date_sub(SUBSTR(FROM_UNIXTIME(UNIX_TIMESTAMP()),1,10),pmod(datediff(SUBSTR(FROM_UNIXTIME(UNIX_TIMESTAMP()),1,10),'1900-01-08'),7)+1), --out 2021-09-05 上周周日
date_sub(SUBSTR(FROM_UNIXTIME(UNIX_TIMESTAMP()),1,10),pmod(datediff(SUBSTR(FROM_UNIXTIME(UNIX_TIMESTAMP()),1,10),'1900-01-08'),7)+3) --out 2021-09-03 上周周五
版权声明:本文为May_Beee原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。