|
-
May 23rd, 2000, 03:53 PM
#1
Thread Starter
New Member
Hi! I hope you can help me with this one.
I'm having a problem on how to extract the number of hours by subtracting field2 by field1 with a combination date & time format.
given two fields:
i.e.
field1 = 2000-05-15 02:17:22
field2 = 2000-05-14 23:24:20
---------------------
total time = 2h:53m:2s
I'm interested on how to extract the total time result and particularly the hours portion.
Thanks in advance 
-
May 23rd, 2000, 07:33 PM
#2
Addicted Member
Do you want to find the difference between to two dates?
Hi,
Are you trying to find the difference between to two dates?
-
May 23rd, 2000, 07:39 PM
#3
Fanatic Member
Try using the Hour,Day and Month Functions. THey return the individual values from a date
month("24/05/00 5:15") returns 5
day("24/05/00 5:15") returns 24
hour("24/05/00 5:15") returns 5
alternatly use the datediff function
Hope this helps
Ian
[Edited by Ianpbaker on 05-24-2000 at 01:40 PM]
Yeah, well I'm gonna build my own lunar space lander! With blackjack aaaaannd Hookers! Actually, forget the space lander, and the blackjack. Ahhhh forget the whole thing!
-
May 24th, 2000, 04:10 PM
#4
Thread Starter
New Member
I'm trying to extract the hours and minutes section for calculation purposes.
You see i'm trying to build a program that charges the online usage of an isp client by calculating the number of hours and minutes used.
Unfortunately the network monitoring software stores the login start-time and stop-time in the format:
yyyy/mm/dd h:mm:ss
So i'm particularly interested in extrating the hours and minutes portion of the field above.
-
May 24th, 2000, 05:00 PM
#5
Fanatic Member
as I said, then use the hour and minute functions to grab the values from any dates, theese will return in an integer format and then you can do your calculations.
Hope this Helps
Ian
Yeah, well I'm gonna build my own lunar space lander! With blackjack aaaaannd Hookers! Actually, forget the space lander, and the blackjack. Ahhhh forget the whole thing!
-
May 26th, 2000, 01:36 PM
#6
Hyperactive Member
This might give you a few ideas. If you're not worried about times exceeding 99:59:59 the format option would work, else the rest of the story...
Code:
Dim str1 As String, str2 As String, str_res as string
Dim dt1 As Date, dt2 As Date, val As Double
Dim hr As Long, mn As Integer, sc As Integer
str1 = "2000-05-15 02:17:22"
str2 = "2000-05-14 23:24:20"
dt1 = CDate(str1)
dt2 = CDate(str2)
val = dt1 - dt2
' option 1
str_res = Format(val, "hh:mm:ss")
' option 2
hr = val * 24
mn = (val * 1440) - (hr * 360)
sc = (val * 86400) - (hr * 360) - (mn * 60)
str_res = hr & "h:" & mn & "m:" & sc & "s"
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
|