Red Hat Bugzilla – Bug 457370
date -d 'last month' returns this month
Last modified: 2008-08-04 06:15:24 EDT
Description of problem:
# LANG=C date
Thu Jul 31 10:00:21 CEST 2008
# LANG=C date -d 'last month'
Tue Jul 1 10:00:27 CEST 2008
Version-Release number of selected component (if applicable):
All, F8 as well.
30 days before today
last month, like in perl
# perl -e 'use DateTime; print DateTime->now;'
# perl -e 'use DateTime; print DateTime->now->subtract(months => 1);'
template1=# select now();
template1=# select now() - interval '1 month';
PS: I know it's not directly RH related, but I don;t know where else to post it.
Thanks for report, that fuzzy behaviour was already reported few times... However - that's not a bug, but documented behaviour which is expected. "Last month" is relative time offset which represents -1 month. For Jul 31, it substracts one month from the date - so the result should be Jun 31. That date is invalid, so it is intentionally interpreted as Jul 1. It is documented in RHEL-5 coreutils (date) info documentation, section 27.6 Relative items in date strings. Solution for scripts is also available in that documentation. Closing NOTABUG.