Solved

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

Posted on 2011-02-21
6
2,833 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
ID: 34941839
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
ID: 34941845
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
ID: 34941848
Use DateAdd function of VB 6.0

Check this:

http://www.vb6.us/tutorials/understanding-vb6s-dateadd-function
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 65

Accepted Solution

by:
RobSampson earned 63 total points
ID: 34941849
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
ID: 34941852
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
ID: 34941871
Cheers!!
0

Featured Post

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

809 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