【问题标题】:Fetching attendance from multiple timestamp and calculating working hours of each employee each day of month从多个时间戳中获取出勤率并计算每个员工每月每天的工作时间
【发布时间】:2018-09-27 12:40:22
【问题描述】:

我有一个数据库,其中我有每个雇员每天的多个时间戳。我想根据每个月的每一天的最小和最大时间戳计算工作时间。

类似这样的:

idx=primary key 
idx  id          date
1   8080   2018-09-25 12:16:12
2   8081   2018-09-25 12:42:06
3   8080   2018-09-25 13:16:12
4   8080   2018-09-25 15:11:11
5   8081   2018-09-25 16:16:33
6   8080   2018-09-26 11:15:12
7   8081   2018-09-26 12:11:12
8   8080   2018-09-26 17:16:12
9   8081   2018-09-26 18:16:12


Desired o/p
id      date        MIN(date)-MAX(date) workhours(in hours)
8080   2018-09-25            04
8081   2018-09-25           3:34
8080   2018-09-26           6:01
8081   2018-09-26           6:05

【问题讨论】:

标签: mysql datetime timestamp time-and-attendance


【解决方案1】:

通过以下查询自己获得了解决方案: SELECT id,min(date),max(date), TIMEDIFF(max(date), min(date))As Diff_Value FROM Attendance GROUP BY DATE(date),id ;

【讨论】:

    猜你喜欢
    • 2022-06-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-06-11
    • 2023-01-20
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多