29
Views
8
Comments
Solved
calculating average time
Application Type
Reactive

I want to calculate the average clockin time of an employee ,by using a expression it gives me an error whats the best possible way to do that ?

HR Portal.oml
Solution

Hi @Muhammad Haseeb 


PFA oml. I implemented for average check in time, you can do the same for checkout time also.

Currently you didnt add any filter in aggregate attendancetracking so it will show average checkin time of first first employee.

Regards,

Pramod.

HR Portal.oml

you add the formula in aggregate convert it into hours then minutes and then sec and store it in local variable and show it on screen ? I'm i correct?


I am taking sum of hours, minutes and seconds from all Intime of particular employee and converting all to total seconds after that taking average of total seconds and forming a time from that average seconds(like dividing by 3600 will give hours and so on for minute and seconds).

Regards,

Pramod.

Hello Muhammad Hasseb, 

Basically, you can calculate the difference of two times using the following expression:

NewTime((DiffSeconds(StartTime,EndTime)/3600),Mod(DiffSeconds(StartTime,EndTime)/60,60),Mod(DiffSeconds(StartTime,EndTime),60))

Best regards, 

Ana

but i want average time

Hello again, 
I believe that, in order to you to achieve that, you might need to follow the steps:

  1. Convert the times you want to use in the average to seconds and store it as an integer/long integer;
  2. Calculate the average between the times in seconds, meaning, the sum of all the times in seconds, and divide it by the total number of values;
  3. Convert the average seconds to a time.

You can check the following links:

Best regards,

Ana

For some reason, I am not able to open your module.

Anyway,

Is the time value saved in an entity attribute of a table?
Does the avarage need to be calculated based on a list of times coming from the database?

If the avarage needs to be calculated based on a list of time values coming from the database you could create an Advanced SQL to have more flexibility on doing this type of calculations

Depending on your database type (syntax may vary) there are many examples available on the internet.
Some examples:
https://stackoverflow.com/questions/14620572/calculate-average-of-time7-in-sql

https://stackoverflow.com/questions/32400056/avg-of-time-in-oracle-sql



Unfortunately, Aggregates do not support the Avarage function for time data types.

yup you are correct , ooh i didnt know about advanced sql yet .

Solution

Hi @Muhammad Haseeb 


PFA oml. I implemented for average check in time, you can do the same for checkout time also.

Currently you didnt add any filter in aggregate attendancetracking so it will show average checkin time of first first employee.

Regards,

Pramod.

HR Portal.oml

you add the formula in aggregate convert it into hours then minutes and then sec and store it in local variable and show it on screen ? I'm i correct?


I am taking sum of hours, minutes and seconds from all Intime of particular employee and converting all to total seconds after that taking average of total seconds and forming a time from that average seconds(like dividing by 3600 will give hours and so on for minute and seconds).

Regards,

Pramod.

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.