views:

293

answers:

1

I have seen a lot of info on how to subtract one datetime from the other and how to add years on to a datetime. but the following is giving me a headache....

When a user inserts a record a hidden field called subdate with a value of datetime.now is added to the db.

I then need to have an 'old records' page that lists all the entries that are over 1 year old and was hoping to use something (but using subtract method) similar to;

(DateTime.Now.AddYears(1))

but there is no SubtractYears available? Why?

Please can you let me know how I achieve the same result?

+8  A: 
DateTime.Now.AddYears(-1)

From the documentation:

A number of years. The value parameter can be negative or positive.

Kobi
its always the simple things :)
Phil
Believe it: it's simply this. A simple solution for a simple problem... a programmer's dream.
Nelson Reis
No way..! You got to be kidding me..
Rosdi