Add 1 week to current date

Go To StackoverFlow.com

10

I've got something like this DateTime.Now.ToString("dd.MM.yy"); In my code, And I need to add 1 week to it, like 5.4.2012 to become 12.4.2012 I tried to convert it to int and then add it up, but there is a problem when it's up to 30.

Can you tell me some clever way how to do it?

2012-04-05 21:39
by René Beneš


26

You want to leave it as a DateTime until you are ready to convert it to a string.

DateTime.Now.AddDays(7).ToString("dd.MM.yy");
2012-04-05 21:41
by Guvante


5

Sure!

DateTime.Now.AddDays(7).ToString("dd.MM.yy"); 
2012-04-05 21:41
by mgnoonan


0

Any reason you can't use the AddDays method as in

DateTime.Now.AddDays(7)
2012-04-05 21:41
by Dan P
Ads