Solved

I need help with Date arithmetic in VB6

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

Independent Software Vendors: 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

Suggested Solutions

Title # Comments Views Activity
How to Have Macro Files Automatically "Edit" 5 47
Set WorkSheet  not Working 9 51
Where to download python requests library 6 62
Web page design problem 3 12
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
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…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

740 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