[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
Solved

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

Posted on 2011-02-21
Medium Priority
3,454 Views
Hi,
Any suggestions on how to  increment and decrement a date by 1.

Cheers
0
Question by:RIAS
[X]
###### Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

• Help others & share knowledge
• Earn cash & points

LVL 12

Assisted Solution

prashanthd earned 248 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

Dhaest earned 252 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)

0

LVL 9

Assisted Solution

s_chilkury earned 248 total points
ID: 34941848
Use DateAdd function of VB 6.0

Check this:

0

LVL 65

Accepted Solution

RobSampson earned 252 total points
ID: 34941849
Hi, in VB6, you use DateAdd:

To get one day subtracted:

Regards,

Rob.
0

LVL 12

Expert Comment

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)
``````
0

Author Closing Comment

ID: 34941871
Cheers!!
0

## Featured Post

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
###### Suggested Courses
Course of the Month13 days, 2 hours left to enroll