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
Solved

I need help with Date arithmetic in VB6

Posted on 2014-01-09
3
349 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
  • 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

A short article about problems I had with the new location API and permissions in Marshmallow
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…

808 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