Reputation: 135
What I need to do is in my program i need to add the Arrival DATE and the Nights staying together and have it display into another textbox called Departure date. The format for the arrival date will be in the "##/##/##" context and the nights staying is an integer between 1 and 14.
I have all of the code for the rest of my program completed, I just do not know how to do this. I dont know how to take an integer and add it to a date so in the display box, after they are added together, it displays a date X amount of days after the arrival days. Where X is the Nights staying.
I Will greatly appreciate any help with this.
Upvotes: 0
Views: 202
Reputation: 223247
Use DateTime.AddDays
to add number of days in the DateTime
object like:
DateTime arrivalDate = new DateTime(2014,03,10);
DateTime departureDate = arrivalDate.AddDays(1); // Add One day
To get the formatted Date back use ToString
with Custom DateTime Formats
string formattedDate = departureDate.ToString("dd/MM/yy", CultureInfo.InvariantCulture);
Upvotes: 1