Solved

I need help with Date arithmetic in VB6

Posted on 2014-01-09
3
343 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 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 450 total points
Comment Utility
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
Comment Utility
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
Comment Utility
Oops... late.
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

This is an explanation of a simple data model to help parse a JSON feed
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…

743 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now