mysql_获取本周星期一的日期
【代码】mysql_获取本周星期一的日期。
·
select
date_format(subdate(now(),date_format(now(),'%w')-1),'%Y-%m-%d')
from
dual
- now()
返回当前日期,也可以用current() - w%
以数字的形式来表示日期为本周的第几天,0为周日,6为周六,以此类推 - date_format(now(),‘%w’)
返回当前日期为本周的第几天 - subdate()
从日期中减去指定的时间间隔,也可以用date_sub(date,INTERVAL expr type) - subdate(now(),date_format(now(),‘%w’)-1)
从当前日期减去距离周一的天数,返回当前日期所在周的星期一 - data_format(date,format)
进行日期格式化,格式可自行设置
更多推荐

所有评论(0)