Solved

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

Posted on 2011-02-21
6
3,111 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 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
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 
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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Not long ago I saw a question in the VB Script forum that I thought would not take much time. You can read that question (Question ID  (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_28455246.html)28455246) Here (http…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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…
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…

717 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