Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 2005 > C# 2005
| Search | Today's Posts | Mark Forums Read
C# 2005 For discussion of Visual C# 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# 2005 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 20th, 2006, 02:25 AM
Authorized User
 
Join Date: Sep 2005
Location: , , .
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Default Getting tomorrow's date?

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

 
Old May 20th, 2006, 02:39 AM
Imar's Avatar
Wrox Author
Points: 70,322, Level: 100
Points: 70,322, Level: 100 Points: 70,322, Level: 100 Points: 70,322, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi Panvuin,

Take a look at the DateTime structure:

http://msdn.microsoft.com/library/de...ClassTopic.asp

It has a number of Add* methods, like AddDays. So this:

DateTime tomorrow = DateTime.Now.AddDays(1);

returns tomorrow's date. This works, because Now itself is a DateTime, so it has an AddDays method...

HtH,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
 
Old May 25th, 2006, 02:03 AM
Registered User
 
Join Date: May 2006
Location: delhi, new delhi, India.
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hi plz try this


string date;
            date = DateTime.Now.AddDays(1).ToString() ;
            textBox1.Text = date;





Similar Threads
Thread Thread Starter Forum Replies Last Post
Show Images from Start Date thru Date istcomnet Classic ASP Basics 2 May 23rd, 2008 07:12 AM
How to find a date range between another date rang tayvonne Access 2 August 3rd, 2006 09:50 AM
Date based query when date is nvarchar MichaelTJ SQL Language 4 January 12th, 2004 09:57 PM
DTS Import ( Date string to Date field) gfowajuh SQL Server 2000 1 September 30th, 2003 06:28 AM
Convert String Date to Date for a SQL Query tdaustin Classic ASP Basics 4 July 7th, 2003 06:01 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.