Summing Value To Days, Hours and Minues

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have this control "txtApparent_Cycle" which value is (23885.02) in seconds. I need to convert this value to number of days, hours and minutes. Is this possible?

I can get the hour value, but, not the numbers of days, hours and minutes involved.

Thanks,.....
 
Syd

See if this gives you a good start on your probelm. In Access (any version)
type Ctrl G and paste this ridiculously long line into the immediate window
and hit enter.

? clng(23885.02) \ (clng(60*60)*24);"Day "; clng(23885.02) \ (60*60) -
(clng(23885.02) \ (clng(60*60)*24))* (clng(60*60)*24) ;"Hr ";
clng(23885.02)\60 - ((clng(23885.02) \ (60*60)) * 60);"Min " ;23885.02 mod
60 ;"Sec "

On my box I get 0 Day 6 Hr 38 Min 5 Sec

Have fun :-)

Ron W
Syd said:
I have this control "txtApparent_Cycle" which value is (23885.02) in
seconds. I need to convert this value to number of days, hours and minutes.
Is this possible?
 
Ron

Thanks, however, the value of 23885.02 works out to be 23885.05(seconds) / 60 = 398.08366 / 60 is in reality 6 hour, 38 minutes and 5 seconds. Is there a shorter method of accomplishing the same thing?

I would appreciate it if there is a shorter method

Thanks,.....


----- Ron Weiner wrote: ----

Sy

See if this gives you a good start on your probelm. In Access (any version
type Ctrl G and paste this ridiculously long line into the immediate windo
and hit enter

? clng(23885.02) \ (clng(60*60)*24);"Day "; clng(23885.02) \ (60*60)
(clng(23885.02) \ (clng(60*60)*24))* (clng(60*60)*24) ;"Hr "
clng(23885.02)\60 - ((clng(23885.02) \ (60*60)) * 60);"Min " ;23885.02 mo
60 ;"Sec

On my box I get 0 Day 6 Hr 38 Min 5 Se

Have fun :-

Ron
Syd said:
I have this control "txtApparent_Cycle" which value is (23885.02) i
seconds. I need to convert this value to number of days, hours and minutes
Is this possible
 
Syd

I am not exactly sure what it is that you are trying to tell me but the line
of vba below gives the same result you got. Are you looking to write a
function that returns the string "0 Days 6 Hours 38 Minutes 5 Seconds" when
passed the number of seconds elapsed?

I am not aware of any "Magic" function in Access (or anywhere else for that
mater) that does this. I recommend that you write a function that first
calculates the numbers of Days in in the total number of seconds.

Days = TotalSeconds \ (CLng(60 * 60) * 24)

Then get the number of hours in the total number of seconds minus the total
number of seconds in the Days that you calculated above.

Hours = (TotalSeconds \ (60 * 60)) - (Days * 24)

Use the same logic to get the minutes

Minutes = (TotalSeconds \ 60) - ((CLng(Days * 24) * 60) + (Hours * 60))

and finally get the seconds using the Mod operator

Seconds = TotalSeconds Mod 60

All thats left to do is make a pretty string

YourString = Days & " Days " & Hours & " Hours " & Minutes & " Minutes " &
Seconds & " Seconds"


Ron W
Syd said:
Ron:

Thanks, however, the value of 23885.02 works out to be 23885.05(seconds) /
60 = 398.08366 / 60 is in reality 6 hour, 38 minutes and 5 seconds. Is there
a shorter method of accomplishing the same thing?
 
Back
Top