Tweeted twitter.com/#!/StackUnix/status/450633463352553472
4 added 136 characters in body
source | link

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?

unix date output

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.

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?

unix date output

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.

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?

unix date output

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.
3 deleted 10 characters in body; edited tags; edited title
source | link

In one of my script, iI 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 I the first time I got a error which drilled down to wrong value as expected 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?

unix date output

Note: TheNote: My process runruns in middle of the day, and hence I don't see any extreme boundary condition like 1 sec got dwindled here and there.

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 I the first time I got a error which drilled down to wrong value as expected 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?

unix date output

Note: The process run in middle of the day, and hence I don't see any extreme boundary condition like 1 sec got dwindled here and there.

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?

unix date output

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.

2 edited tags; edited title
| link

Unix Why date - strange issue incorrect output X-3 instead X-2 days when I am doing arithmetic operations

1
source | link