Solved

I need help with Date arithmetic in VB6

Posted on 2014-01-09
3
360 Views
Last Modified: 2014-01-09
Hello Experts,
I need help with Date arithmetic in VB6.  I have a variable, which I will set to today's date.  Then I want to perform some Date arithmetic against that value.
For example:

Dim dteToday as Date
dteToday = '1/9/2014'

If I want the following result to be '1/11/2014', would I simply do this?
dteToday = dteToday +2

Of If I want the following result to be '1/6/2014', would I simply do this?
dteToday = dteToday - 3

Please let me know how to do this.  Thanks in advance.
mrotor
0
Comment
Question by:mainrotor
[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
  • 2
3 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 450 total points
ID: 39768264
yes, you can do that.
another way would be:

dteToday = dateadd("d", 2, dteToday)
respectively:
dteToday = dateadd("d", -3, dteToday)

http://msdn.microsoft.com/en-us/library/aa262710%28v=vs.60%29.aspx
0
 
LVL 25

Assisted Solution

by:Luis Pérez
Luis Pérez earned 50 total points
ID: 39768285
As long as you want to add or subtract days, there's no problem. You can do only by adding or subtracting a number. If you want to operate with another time unit (weeks, months...) you should use the DateAdd function.

Hope that helps.
0
 
LVL 25

Expert Comment

by:Luis Pérez
ID: 39768290
Oops... late.
0

Featured Post

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!

Question has a verified solution.

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

Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
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…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

737 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