FB> I noticed a daily script was giving out some incorrect output, and looking FB> at it more closely I saw that the date function assumes a 30-day month:
JXH> Well, April really does have only 30 days. Right, that's the thing: If it's May 31st, then what would you expect "one month ago" to mean? There is no April 31st, and April 30th is one month before May 30th, not May 31st. (But May 1st is one month before June 1st; so this seems like a genuinely hard case. FWIW: +$ date -d '+1 month' Sun Jul 1 10:42:05 EDT 2012 (Ubuntu 10.04, GNU coreutils 7.4) I think it just doesn't know what to do if the next (or previous) month doesn't have a day that matches the current month. More: +$ date -d '+3 months' Fri Aug 31 10:42:58 EDT 2012 +$ date -d '+90 days' Wed Aug 29 10:43:00 EDT 2012 So it's not "month = 30 days', because it thinks that "3 months" and "90 days" are different. +$ date -d '-3 months' Fri Mar 2 09:43:02 EST 2012 That's because not only is there no Feb 31st, there's not even a Feb 30th. +$ date -d '-4 months' Tue Jan 31 09:43:08 EST 2012 When it hits a month with a 31st, it does the right thing. ticket.close(worksforme) -Josh (iril...@infersys.com) _______________________________________________ Tech mailing list Tech@lists.lopsa.org https://lists.lopsa.org/cgi-bin/mailman/listinfo/tech This list provided by the League of Professional System Administrators http://lopsa.org/