Go Back  Xtreme Visual Basic Talk > Visual Basic .NET (2002/2003/2005/2008, including Express editions) > .NET General > Add 1 month to date


Reply
 
Thread Tools Display Modes
  #1  
Old 10-08-2006, 05:48 PM
tonymaclennan tonymaclennan is offline
Contributor
 
Join Date: Sep 2004
Location: Lincolnshire
Posts: 402
Default Add 1 month to date


I have a variable name called:

Dim DateUntil as date

How (using VB.NET VB) would I add 1 month to this date?

Thanks
Reply With Quote
  #2  
Old 10-08-2006, 06:10 PM
OnErr0r's Avatar
OnErr0r OnErr0r is offline
Obsessive OPtimizer

Administrator
* Guru *
 
Join Date: Jun 2002
Location: Debug Window
Posts: 13,726
Default

Use DateTime.AddMonths.
__________________
Quis custodiet ipsos custodues.
Reply With Quote
  #3  
Old 10-09-2006, 12:31 AM
Cags's Avatar
Cags Cags is offline
Contributor

* Expert *
 
Join Date: Jul 2003
Location: Leicestershire, England
Posts: 710
Default

It's worth noting the AddMonths method returns a new date with the month added, rather than changing the month value of the variable it's called on. Just thought I'd mention it because this is something that trips alot of people.
__________________
I don't suffer from insanity, I enjoy every minute of it.
http://www.tib-studios.co.uk
Reply With Quote
  #4  
Old 10-09-2006, 04:35 PM
tonymaclennan tonymaclennan is offline
Contributor
 
Join Date: Sep 2004
Location: Lincolnshire
Posts: 402
Default

Using that method, all I could figure out was:
DateTime.Now.AddMonths(1)

But I want to add 1 month to the date in my variable (DatePaidUntil) - how do I do this?
Reply With Quote
  #5  
Old 10-09-2006, 04:52 PM
OnErr0r's Avatar
OnErr0r OnErr0r is offline
Obsessive OPtimizer

Administrator
* Guru *
 
Join Date: Jun 2002
Location: Debug Window
Posts: 13,726
Default

Code:
DatePaidUntil = DatePaidUntil.AddMonths(1)
__________________
Quis custodiet ipsos custodues.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
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

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->