Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > General > Adding days to a date

Thread Tools Display Modes
Old 03-14-2008, 12:06 PM
lupusk9 lupusk9 is offline
Join Date: Nov 2003
Location: Mesa, Arizona
Posts: 90
Unhappy Adding days to a date

I already know of the datediff() function, which has helped me in the program thus far. I'm wandering how (to easily) to add basically two weeks to a date.

My program is set up basically so you cant really do anything until you enter the starting date of two weeks. Its for calculating how many hours you've worked in the two week pay period. I'm trying to auto fill the boxes with the date at least so all they have to do is enter the time.

I want to figure this part out because if they enter say 03/20/08 and it adds 14, currently it does not know that a new month will begin before this two week period ends. I could probably figure it out with a bunch of loops or case statements but I'm just wandering if there's like an opposite function to datediff. OR if theres a function OF datediff that i have not recognized yet that will do this. I use it to calc the seconds right now between the two dates and get my info from there... i haven't tried much else...

any thoughts or tips you experts could give me?
Reply With Quote
Old 03-14-2008, 12:20 PM
Flyguy's Avatar
Flyguy Flyguy is offline
Lost Soul

Super Moderator
* Guru *
Join Date: May 2001
Location: Vorlon
Posts: 19,098

You can use the DateAdd method, or just add the number of days to the date variable.
Dim myDate As Date ' Add 2 weeks using days myDate = Now() + 14 ' Add 14 days using the DateAdd myDate = DateAdd("d", 14, Now) ' Add 14 days using the DateAdd myDate = DateAdd("w", 2, Now)
Reply With Quote
Old 03-14-2008, 12:25 PM
lupusk9 lupusk9 is offline
Join Date: Nov 2003
Location: Mesa, Arizona
Posts: 90

There's a dateadd function?! Dang i guess i should have scrolled through the msdn

Thank you so much!
Reply With Quote
Old 03-14-2008, 03:05 PM
loquin's Avatar
loquin loquin is offline
Google Hound

Retired Moderator
* Guru *
Join Date: Nov 2001
Location: Arizona, USA
Posts: 12,398

There's also a DateDiff function... which is also pretty useful.
"I have my standards. They may be low, but I have them!" ~ Bette Middler
"It's a book about a Spanish guy called Manual. You should read it." ~ Dilbert
"To understand recursion, you must first understand recursion." ~ unknown
Reply With Quote

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


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.
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
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..