Solved

time subtraction !!

Posted on 2002-03-14
3
244 Views
Last Modified: 2012-05-04
i am having 2 text boxes both are having time as the text in standard format how can i subtract both the times and get the net time for which the application was running?
0
Comment
Question by:pranay01
3 Comments
 

Expert Comment

by:RanjiniPraba
ID: 6867553
Hi,
you can use the Datediff() function whereby you will have to pass 3 arguments,
two of which are the dates for which you have to find the difference. the last argument is the format in which you want the difference like h for hour, s for seconds, m for months, d for days, etc. once you get the difference, you can convert it in to time again which is a simple arithmetic.
0
 

Accepted Solution

by:
stevengann earned 50 total points
ID: 6877464
Dim TheDate As Date   ' Declare variables.
Dim Msg
TheDate = InputBox("Enter in this format ->  " & Now)
Msg = "Hours from now: " & DateDiff("h", Now, TheDate)
MsgBox Msg
Msg = "Minutes from now: " & DateDiff("n", Now, TheDate)
MsgBox Msg
Msg = "Seconds from now: " & DateDiff("s", Now, TheDate)
MsgBox Msg
0
 

Author Comment

by:pranay01
ID: 6878832
thanx it worked!!
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

758 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

21 Experts available now in Live!

Get 1:1 Help Now