Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > C# and C > C# 2005 > C# 2005
Password Reminder
Register
| FAQ | Members List | Calendar | 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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
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

  #2 (permalink)  
Old May 20th, 2006, 02:39 AM
Imar's Avatar
Wrox Author
Points: 72,055, Level: 100
Points: 72,055, Level: 100 Points: 72,055, Level: 100 Points: 72,055, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,086
Thanks: 80
Thanked 1,587 Times in 1,563 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
  #3 (permalink)  
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;

 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 07:52 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.