MikeDave888
Programmer
Hello everyone,
I am getting inconsistent days between two dates as below. Any idea? Any feedback would be greatly appreciated. Thank you everyone!
# This returns 42 days -- which is correct
> echo $(((`date +%s -d '2020/02/02'` - `date +%s -d '2019/12/22'`) / 86400)) days
42 days
# This returns 83 days -- which is incorrect. I am expecting 84 days
> echo $(((`date +%s -d '2020/03/15'` - `date +%s -d '2019/12/22'`) / 86400)) days
83 days
> echo $((($(date --date="2020/03/15" +%s) - $(date --date="2019/12/22" +%s)) / 86400)) days
83 days
Thanks and Regards,
Mike
I am getting inconsistent days between two dates as below. Any idea? Any feedback would be greatly appreciated. Thank you everyone!
# This returns 42 days -- which is correct
> echo $(((`date +%s -d '2020/02/02'` - `date +%s -d '2019/12/22'`) / 86400)) days
42 days
# This returns 83 days -- which is incorrect. I am expecting 84 days
> echo $(((`date +%s -d '2020/03/15'` - `date +%s -d '2019/12/22'`) / 86400)) days
83 days
> echo $((($(date --date="2020/03/15" +%s) - $(date --date="2019/12/22" +%s)) / 86400)) days
83 days
Thanks and Regards,
Mike