Solved

How to increment and decrement a date by 1+visual basic 6.0

Posted on 2011-02-21
6
2,710 Views
Last Modified: 2012-06-21
Hi,
Any suggestions on how to  increment and decrement a date by 1.

Cheers
0
Comment
Question by:RIAS
6 Comments
 
LVL 12

Assisted Solution

by:prashanthd
prashanthd earned 62 total points
Comment Utility
Try this

Dim NextTime As Date = Now        ' Current date and time.
NextTime = NextTime.AddDays(3.4)  ' Increment by 3 2/5 days.
0
 
LVL 53

Assisted Solution

by:Dhaest
Dhaest earned 63 total points
Comment Utility
Did you look at the dateAdd-function. You can add 1 day (interval = d, number = 1) or subtract one (interval = d, number = -1)

VBSCRIPT:http://www.w3schools.com/Vbscript/func_dateadd.asp
VB6: http://www.vb6.us/tutorials/understanding-vb6s-dateadd-function
0
 
LVL 9

Assisted Solution

by:s_chilkury
s_chilkury earned 62 total points
Comment Utility
Use DateAdd function of VB 6.0

Check this:

http://www.vb6.us/tutorials/understanding-vb6s-dateadd-function
0
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
LVL 65

Accepted Solution

by:
RobSampson earned 63 total points
Comment Utility
Hi, in VB6, you use DateAdd:

To get one day subtracted:
dteNewDate = DateAdd("d", -1, Now)

To get one day added:
dteNewDate = DateAdd("d", 1, Now)

Regards,

Rob.
0
 
LVL 12

Expert Comment

by:prashanthd
Comment Utility
You can also try this code
Dim Msg, Number, StartDate As String   'Declare variables.
Dim Months As Double
Dim SecondDate As Date
Dim IntervalType As DateInterval
IntervalType = DateInterval.day   ' Specifies months as interval.
StartDate = InputBox("Enter a date")
SecondDate = CDate(StartDate)
Number = InputBox("Enter number of days to add/subtract")
days = Val(Number)
Msg = "New date: " & DateAdd(IntervalType, days, SecondDate)
MsgBox(Msg)

Open in new window

0
 

Author Closing Comment

by:RIAS
Comment Utility
Cheers!!
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now