15 Replies Latest reply: May 19, 2014 7:08 AM by James Clark

# Time Calculations

Hi All

I need to find out how I can multiply a number of hours by expected personnel, to get total hours booked to event.  the calculation to get the Hours are

if(interval(EndTime - StartTime,'hh:mm')<0, interval(Date(EndTime,'ddmmyy')+1 - StartTime,'hh:mm'),interval(EndTime - StartTime,'hh:mm') )as [Total_Hours] and the personnel Expected is a sum of numbers.  so the total booked hours should be 21:00, but I cant workout how I can calculate a time calculation by a number calculation. am i missing something

can anyone help.

• ###### Re: Time Calculations

Could you post your sample qvw?

• ###### Re: Time Calculations

Hi tresesco

I have attached an example now.

thanks

• ###### Re: Time Calculations

Hi sorry about that i forgot it had section access. i have remove this now and re-uploaded

• ###### Re: Time Calculations

First, you have too many formatting functions in your expression. Remove them: They do not change the calculations; they just prevent you from seeing the structure of your expression. Instead of

If(  interval(EndTime - StartTime,'hh:mm')<0,

interval(Date(EndTime,'ddmmyy')+1 - StartTime,'hh:mm'),

interval(EndTime - StartTime,'hh:mm')

) as [Total_Hours]

you should write

Interval(

If(  EndTime - StartTime <0,

EndTime +1 - StartTime,

EndTime - StartTime ),

'hh:mm' ) as [Total_Hours]

If you want to format it, you should put the formatting function as the outermost function.

Secondly, if EndTime and StartTime are correctly interpreted, they have numeric values where a difference of one day is 1, and a difference of one hour is 1/24. This means that you can get the number of hours through

(EndTime - StartTime) * 24

HIC

• ###### Re: Time Calculations

Can you share the credentials to login to your application?

• ###### Re: Time Calculations

I was trying open your sample document but it was asking the user ID

try with below

Expected hours = Personel expected*(Totalhours*24)

In total hours you can use your actual expression

• ###### Re: Time Calculations

I tried and it worked

DDT_Hours*24)*[Personnel Expected]

• ###### Re: Time Calculations

Hi Jebamalai

thanks for taking a look,i need the output to be formated to hh:mm.  can you help?

regards

James

• ###### Re: Time Calculations

change your expression to

(DDT_Hours)*[Personnel Expected]

and change the format to Time->hh:mm from the number tab

it works

• ###### Re: Time Calculations

Hi

i have already changed this and it just shows 00:00 for all values now! are you able to amend the example?

thanks Jebamalai

• ###### Re: Re: Time Calculations

Hi James

Pls check and let me know

Regards

Jeba

• ###### Re: Time Calculations

Hi Jeba

The third calculation isnt correct it should show 50:00, it shows 02:00 in the example

regards

James

• ###### Re: Re: Time Calculations

Oh sorry.

Pfa the updated one

• ###### Re: Time Calculations

Hi Jeba

that's perfect thanks for your help

regards

James