Solved

time subtraction !!

Posted on 2002-03-14
3
247 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone 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

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
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…
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…

827 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