[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
6
Medium Priority
?
3,454 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
[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
  • Learn & ask questions
6 Comments
 
LVL 12

Assisted Solution

by:prashanthd
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

by:Dhaest
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)

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 248 total points
ID: 34941848
Use DateAdd function of VB 6.0

Check this:

http://www.vb6.us/tutorials/understanding-vb6s-dateadd-function
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 65

Accepted Solution

by:
RobSampson earned 252 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

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

650 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