In one of my script, I need to find a 2 days back date from a given date. I have been using the below without any issue since long time, but it's just the first time I got a error which drilled down to wrong value by date command.
$ date -d 20140331" - 2 days" +%Y%m%d
Expected output
20140329
Actual output
20140328
Using "- 2 days" gives expected output, but still struggling to find why subtracting seconds didn't work?
Note: My process runs in middle of the day, and hence I don't see any extreme boundary condition like 1 sec got dwindled here and there.
Some more info
$ date --version
date (GNU coreutils) 5.97
Copyright (C) 2006 Free Software Foundation, Inc.
date -d 20140331" - 172800 seconds" +%Y%m%d
I get20140329
. @manatwork Lol no. This is a whole day (look at the numbers closely)!