Description of problem: Command: date -d last-month +%Y%m date -d next-month +%Y%m doesn't return the correct result on March 31, 2008 Version-Release number of selected component (if applicable): coreutils-5.97-12.1.el5 How reproducible: It can be reproduced. Steps to Reproduce: 1.Change the system date to March 31, 2008 # date 0331010108 Mon Mar 31 01:01:00 CST 2008 2.run command: date -d last-month +%Y%m result: 200803 3.run command: date -d next-month +%Y%m result: 200805 Actual results: Expected results: 200802 200804 Additional info: Change the date to March 30, 2008, next-month reports the correct result, but last-month doesn't. Change the date to May 31, 2008, the results are incorrect either.
Sorry, that's not a bug, but expected behaviour and in fact frequently asked question. Last month works like: 2008 03 31 - 1 month = 2008 02 31 -> invalid date -> change it to valid date -> 2008 03 02 -> that's the output Next month works like: 2008 03 31 + 1 month = 2008 04 31 -> invalid date -> change it to valid date -> 2008 05 01 -> that's the output This behaviour is expected and can't be changed. For details and way how to get correct month if you need, you could see coreutils documentation , section 27.6, Relative items in date strings (here is online version: http://www.gnu.org/software/coreutils/manual/html_node/Relative-items-in-date-strings.html ) Closing NOTABUG.