adding time lengths (1 Viewer)

shutzy

Registered User.
Local time
Today, 01:25
Joined
Sep 14, 2011
Messages
775
I have a report that shows the daily activities. it shows how long it takes to do each task. however some tasks are 8 hours andsome are 10 hours. when all these times are added together it will give the time on a clock. not a total of hours spent.

ie.
treatment1 : 8 hours
treatment2: 10 hours

this will give 06:00 in short time. in medium time it will give 18:00.

however if I add another 12 hours to that it will give 06:00.

I want it to show either 1 day and 4 hours /or 30 hours

how do I do this?
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 01:25
Joined
Sep 12, 2006
Messages
15,662
the accumulated time is actually held as x days, and so many hours. The time element just shows the time bit.

so given a date/time value, declare a double, and then the hours are given by

elapsedhours = mytime * 24
so eg 1 day 6hrs, will be stored as 1.25 days, but will now be resolved as 30 hours.


and total minutes by

elapsedminutes= mytime * 24 * 60
 

shutzy

Registered User.
Local time
Today, 01:25
Joined
Sep 14, 2011
Messages
775
how do I format the text box to that. I already have short time in them. do I have to change them all to

elapsedhours = mytime*24

ive tried what I have just said and it doesn't work as though I expected. I knew it wouldn't be that easy but....
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 01:25
Joined
Sep 12, 2006
Messages
15,662
the easiest way is to add another text box. define it as general number and set the source to

= [timebox]*24

or set it in code somewhere.

You could make the "real underlying" timer controls invisible, if it helps.
 

shutzy

Registered User.
Local time
Today, 01:25
Joined
Sep 14, 2011
Messages
775
thank you for that. is there a way to display eg. 68 hours and 45 minutes. if its too complicated im happy with 68.75 hours. we only have treatments in 15 minute increments anyway so it wouldn't be a long decimal. I think I can cope with 1/4
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 01:25
Joined
Sep 12, 2006
Messages
15,662
well you would then have to use mod, and int say to get the whole number, and the decimal portion, and treat it as a string

something like this

=int([mytime]/60) & "hours " & mod([mytime]/60) & " mins
 

shutzy

Registered User.
Local time
Today, 01:25
Joined
Sep 14, 2011
Messages
775
thanks for that but I think ill leave it as hours.

hopefully that last post isn't wasted and just got your brain working for the day.

thanks again
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 01:25
Joined
Sep 12, 2006
Messages
15,662
time is fiddly to deal with. not like dates, where you can have a date-picker. you can't really have a time-picker

the other way is to have two text boxes, one showing the hours and one the minutes.


you could turn this into a 24-hour clock type thing, also

Int([mytime] * 24) & ":" & Format(([mytime] * 24) Mod 60, "00")


(please note - my last attempt at this was off - the above use of mod is correct)
 
Last edited:

Users who are viewing this thread

Top Bottom