Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting tomorrow's date

Status
Not open for further replies.

panuvin

Programmer
Mar 24, 2004
11
US
Hello,

I'm a C# newbie using VS.NET 2005. I'm having trouble getting a string representation of a date and using addition in DateTime objects to get tomorrow's date.

I have two ways of acquiring the current date. I use both:

Code:
DateTime dtNow = DateTime.Now;
string strDateNow = dtNow.ToString("MM/dd/yyyy");

AND

Code:
string dateCal2 = this.monthCalendar1.SelectionStart.ToString();

What's the easiest way to acquire the date for tomorrow? I can't seem to find any applicable function in the SDK and I'd hate to re-invent the wheel by creating an entire date class. Thanks in advance!

Panvuin
 
Try:
Code:
// Get current date-time
DateTime today = DateTime.Now;

// Add one day
DateTime tomorrow = today + new TimeSpan(1, 0, 0, 0);

// Show it
Console.WriteLine(tomorrow.ToString("MM/dd/yyyy");
Chip H.


____________________________________________________________________
If you want to get the best response to a question, please read FAQ222-2244 first
 
How about this?

Code:
// Get tomorrow's DateTime
DateTime dtTmrw = DateTime.Now.AddDays(1);

// Show it
Console.WriteLine(dtTmrw.ToShortDateString());
 
That'll work too.
And is much simpler than mine!
:)

Chip H.


____________________________________________________________________
If you want to get the best response to a question, please read FAQ222-2244 first
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top