Linux上获取各日期参数 1、当前日期
2、本月初 - first_day=`date -d"${sysdate}" +%Y%m01`
复制代码
3、上月末 - last_mon=`date -d"${first_day} last day" +%Y%m%d`
复制代码
4、上年末 - last_year=`date -d"${sysdate} last year" +%Y1231`
复制代码
5、上季度末 - curr_month=`date -d"${sysdate}" +%_m`
- curr_quarter=$((($curr_month-1)%3))
- next_mon=`date -d "${sysdate} $curr_quarter months ago" +%Y%m01`
- last_q=`date -d "${next_mon} last day " +%Y%m%d`
复制代码
如有特殊需求,获取特殊日期,可以留言讨论。 |