|
-
Apr 19th, 2000, 11:02 PM
#1
I have a start time & End time variables. I'm trying add the times together to get the total time it took for a project.
It's really not a big deal on how the text has to be laid out in the text box. Right now I have it like this
830 for 8:30
For PM I'm adding 12 hours to the time so I don't end up with negative numbers.
I'm not having any luck with any of this. Can somebody plase help me out on this?
Ken Devorak
-
Apr 19th, 2000, 11:12 PM
#2
Frenzied Member
I believe the function you are after is DateDiff
eg;
dim StartTime as Date
dim EndTime as Date
dim NumHours as Integer
dim NumMinutes as Integer
StartTime="08:00" 'eg 8am
EndTime="14:30" 'eg 2:30pm
NumHours=DateDiff("h",StartTime,Endtime)
NumMinutes=Datediff("n",StartTime,EndTime)
'this will return 6 hours, and 390 minutes.
'to get the actual hours and minutes we need to take
'60x6 away from 390...
NumMinutes=NumMinutes-(60*NumHours)
Msgbox "Time Elapsed: " & NumHours & "hrs " & NumMinutes & "mins"
Basically, you use the DateDiff function like this;
[var]=DateDiff("[type]",[start],[end])
where [type] =
[d] = days
[m] = months
[y] = years
[h] = hours
[n] = minutes
[s] = seconds
..there's more - look it up in the help.
'Buzby'
Visual Basic Developer
"I'm moving to Theory. Everything works there."
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|