
Announcements
Hello
So I am creating an app that measures how many hours of the "core time" each employee actually covers each day.
So for the sake of discussion, let us assume this scenario:
Core time: 0900-1400. During this time, everybody must be present.
Therefore, I need to measure the clock in/out time of the employee and see how much of this time acutally overlaps this time interval. Any ideas on how to solve this?
Hi @Anonymous ,
Based on your description, here's my idea:
Create two buttons, one for online, one for offline. Make employee click the online button when he works, click the offline button when he rests. Update these time information and then filter based on time and employee name, sum up the result.
I've made a similar test for your reference:
1)insert two buttons, one for online one for offline.
2)set this screen's OnVisible:
//create table's structure, or else you can not update later
Collect(worktime,{name:Blank(),onlinetime:Blank(),offlinetime:TimeValue(Blank()),date:Blank()})
//please note that you need to use offlinetime:TimeValue(Blank()), or else you can not update this field (blank() and TimeValue is not the same data type)
set online button's OnSelect:
If(IsEmpty(
Filter(worktime,Not(name=Blank())))||
!IsBlank(Last(Filter(worktime,Not(name=Blank()))).offlinetime),
Collect(worktime,{name:User().FullName,email:User().Email,
onlinetime:TimeValue(Text(Now(),DateTimeFormat.ShortTime)),
date:Today(),
offlinetime:TimeValue(Blank())}),
Notify("you haven't ended working!",NotificationType.Warning))
//only if the last record's offlinetime is not blank, then you could create a new record
set offline button's OnSelect:
UpdateIf(worktime,offlinetime=TimeValue(Blank())&&email=User().Email&&date=Today(),{offlinetime:TimeValue(Text(Now(),DateTimeFormat.ShortTime))})
//only if the last record's offlinetime value is blank, then you could update offlinetime column
3)insert a label to display this employ today's worktime, set the label's Text:
Sum(
AddColumns(
Filter(worktime,email=User().Email,
date=Today(),
(Time(9,0,0)<=onlinetime&&Time(14,0,0)>onlinetime)||
(Time(9,0,0)<offlinetime&&Time(14,0,0)>=offlinetime)
),
//filter valid record that time is from 9 to 14
"worktime",
If(onlinetime<Time(9,0,0)&&offlinetime>Time(9,0,0)&&offlinetime<Time(14,0,0),
DateDiff(Time(9,0,0),offlinetime,Minutes),
onlinetime<Time(9,0,0)&&offlinetime>Time(14,0,0),
300,
onlinetime>Time(9,0,0)&&onlinetime<Time(14,0,0)&&
offlinetime>Time(9,0,0)&&offlinetime<Time(14,0,0),
DateDiff(onlinetime,offlinetime,Minutes),
onlinetime>Time(9,0,0)&&onlinetime<Time(15,0,0)&&offlinetime>Time(14,0,0),
DateDiff(onlinetime,Time(14,0,0),Minutes))
),
//count worktime in four situations
worktime
)&"minutes"
Best regards,