The stock OS X date command ships with a useful -v command that allows date calculation. For example, to determine the last day of February, you could use the following:
date -v3m -v1d
That's the third month in the first -v, and then less one day in the second -v. man date gives many examples. On the other hand, the Gnu version of date that's available from MacPorts does not support this option. Playing a bit with the --date option for Gnu's date, I came up with:
date --date="march 1 1 day ago"
This results in the same date calculation as in the stock date function. Gnu's date also includes the option of printing rfc-2822 and rfc-3339 dates. The latter can be used for applications like Google that require xls dates:
date --rfc-3339='ns'
2008-07-23 18:28:00.110568000+05:30
The ns means nano-seconds.
Mac OS X Hints
http://hints.macworld.com/article.php?story=20080723060344662