Determining a DateTime by adding a number of Days to a Date - Help

G

Guest

I have a loop where I need to calculate a series of dates based on:
1) a start date (DateTime variable)
2) a number of days (integer variable)

I need to take the start date, then add the number of days to it, and come
up with the next date.

eg.
- DateTime variable might equal 01/02/2005
- My integer for "Number of Days" is 10
- I need to take my DateTime variable (01/02/2005) and add the integer 10
(for 10 days) to it. This should produce the result of 01/12/2005 as a
DateTime variable.

Any ideas on how to go about this?
 
D

Dennis Myrén

Try this.

DateTime origDate = DateTime.Now;
DateTime result = origDate.AddDays(10);
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top