change date

  • Thread starter Thread starter andrewbda
  • Start date Start date
A

andrewbda

quick question here.

I have a date variable that I would like to change. I need to add 364
days to it, i.e. I need year+1, day-1.

any help is appreciated!

Thanks
 
It would be nice and easy to use DateTime.Now.AddDays(364) but this would
give a result that is a day short where a leap year is involved.

To be leap year safe, you need to use:

DateTime.Now.AddYears(1).AddDays(-1)
 
Back
Top