Windows Develop Bookmark and Share   
 index > Windows Forms General > DateTime Inc - but how?
 

DateTime Inc - but how?

Hi :)

I would like to increment a datetime variable, but it doesn't work.

System.DateTime dt = System.DateTime.Now;

dt.addDays(1) and dt.date = dt.date +1 and dt++ doesn't work

But how can I increment the date (one day)??

Codeschubser  Tuesday, September 22, 2009 10:35 AM

assign it back to your variable..
dt = dt.AddDays(1);


:: Learning .NET ::
Prasant Swain  Tuesday, September 22, 2009 10:42 AM
DateTime dt = DateTime.Now;
dt=dt.AddDays(1);

also you can use AddMonths, AddYears,AddHours etc
  • Proposed As Answer byTamer OzMVPTuesday, September 22, 2009 10:42 AM
  •  
Tamer Oz  Tuesday, September 22, 2009 10:42 AM

assign it back to your variable..
dt = dt.AddDays(1);


:: Learning .NET ::
Prasant Swain  Tuesday, September 22, 2009 10:42 AM
Thank you to both of you for the fast response.

It works perfect. :)
Codeschubser  Tuesday, September 22, 2009 10:52 AM

You can use google to search for other answers

Custom Search

More Threads

• validate the user input in setup installer
• Form Layouts...
• menu navigation standards?
• Web Browser function...
• Menu Help Please
• How to deal with null values and the datetimepicker
• Using Threads in Serial port Connection
• Print .msg File
• downloading updates
• Font changes between client and my computer