Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I need help with Time arithmatic in VB6 3

Status
Not open for further replies.

elmorro

Programmer
Jun 23, 2005
133
0
0
US
Hi all,
I have a program that gathers an employees Start and End time spent working on a given order. I need to help finding the duration in minutes.
Here is an example of the data gathered.
Start Time: 10:30:00 AM
End Time: 12:30:00 PM
The duration should be 120 minutes.
How can I do this?


Thanks in advance,
elmorro :)
 




Hi,

Date/Time is in units of DAYS.

So take the difference and you get a portion of a day. Convert days to minutes .
Code:
tStart = #10:30:00 AM#
tEnd = #12:30:00 PM#

MsgBox (tEnd - tStart) * 24 * 60


Skip,
[sub]
[glasses] [red][/red]
[tongue][/sub]
 
Thanks TipGiver and SkipVought for your quick response.

elmorro :)
 
TipGiver's idea does work in minutes:
Code:
Dim strStart As String
Dim strEnd As String

strStart = "02/09/2007 10:30:00 AM"
strEnd = "02/09/2007 12:30:00 PM"

MsgBox DateDiff("n", strStart, strEnd)

[blue]120 minutes[/blue]

Have fun.

---- Andy
 
It can take the following values:

yyyy - Year
q - Quarter
m - Month
y - Day of year
d - Day
w - Weekday
ww - Week of year
h - Hour
n - Minute
s - Second

You can also use (not pretty sure) instead of the above the 'DateInterval.{something}'
 
Thanks Adrzejek and TipGiver. The code works great!

elmorro :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top