Pacific-Design.com

    
Home Index

1. Bash

2. Date

Bash / Date /

Today - 1 Month

$ echo $(date '+%C%y-%m-%d' -d "-1 month")
2010-07-25

Calculate Start and End Date from Today - 3 days


today=$(date '+%m/%d/%C%y' -d "-3 days")
bimonthly=$(date "--date=${today} -3 month" +%m/%d/%Y)
biweekly=$(date "--date=${today} -14 days" +%m/%d/%Y)
monthly=$(date "--date=${today} -1 month" +%m/%d/%Y)

echo "Bimonthly: $bimonthly - $today"
echo "Biweekly:  $biweekly - $today"
echo "Monthly:   $monthly - $today"

---------------------------------------------

Bimonthly: 05/22/2010 - 08/22/2010
Biweekly:  08/08/2010 - 08/22/2010
Monthly:   07/22/2010 - 08/22/2010

One day ago

 echo $(date -d '1 day ago' '+%C%y-%m-%d')
 
 #Response: 2017-08-09