Solved

Difference in minutes between two dates

Posted on 2000-03-05
3
153 Views
Last Modified: 2010-05-02
Let say i have a Date Variable declared as

CurrentTime as date

and i have string populated with this

oldtime=now

how can i check to see if the difference in minutes bewtween old time and current time is more than 30 minutes. i tried saying

if currenttime-cdate(oldtime)<30 then
...
but of course that was wrong...

thankyou
Jon Hess
0
Comment
Question by:jonjhess
  • 2
3 Comments
 

Author Comment

by:jonjhess
ID: 2586194
Well that was full of errors.. it should be > but i'm sure that you see what i mean. i just need to find the difference between two times in minutes when one time is in a date data type and the other in a string.
0
 

Accepted Solution

by:
ballpc earned 50 total points
ID: 2586308
Jon,

Use the DateDiff function...

Dim CurrentTime       As Date
 
CurrentTime = "3/5/2000 11:00:00PM"
 
If DateDiff("n", CurrentTime, Now) = 30 Then
    MsgBox "It's been 30 minutes!"
Else
    MsgBox "It's been " & DateDiff("n", CurrentTime, Now) & " minutes!"
End If
0
 

Author Comment

by:jonjhess
ID: 2590006
Thankyou
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

831 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