Topic: substracting days from Date

I would like to go back 14 days (or months, or years) from today's date. How would I do that?

I tried - 10

. This returns the days minus 10 days, but does not return the whole date. So for example, if today's date is 2006-11-10 and I want to go back 14 days, I want the date to be returned as 2006-10-27. Format doesn't matter. I am just using 'YYYY-MM-DD'.

Thanks for the help!

Last edited by Jammer1982 (2006-11-10 11:46:46)

Re: substracting days from Date

Try - 10

Re: substracting days from Date

Ok...I tried that initially and I was getting an error. But now I realize why I was getting that error. I was getting my offset from a params field, which resulted essentially in trying to substract a string from - offset

Instead, I tried: - offset.to_i

which is working perfectly.

Thank you!