在计算出时间时使用Crystal Report员工

时间:2016-06-15 14:35:46

标签: sql-server crystal-reports

我有员工出勤软件和这样的数据

emp id     Date             Time    
1         15/06/16          08:00 12:30  01:00 08:00        
2         15/06/16          08:00 12:30  01:00 07:30

如何使用水晶报告计算当天的总小时数?

例如:
emp id 1 on date 15/06/16总工作日为12小时 和
emp id 2 on the date 15/06/16总工作日是11:30小时。

1 个答案:

答案 0 :(得分:0)

试试这个:

创建公式:

Split(Totext(database.Time)," ")[1]& " "&"in time"&ChrW(13)
Split(Totext(database.Time)," ")[2]& " "&"out time"&ChrW(13)
Split(Totext(database.Time)," ")[3]& " "&"in time"&ChrW(13)
Split(Totext(database.Time)," ")[4]& " "&"out time"

详细部分

编辑..............

创建一个公式并在下面写下代码并放在数据库字段之后:

注意:Database.fieldname包含08:00 12:30 01:00 08:00整个字符串

Numbervar starthour;
Numbervar startminute;
Numbervar endhour;
Numbervar endminute;
Numbervar Finalhour;
Numbervar Finalminute;
Numbervar i:=0;



starthour:=(ToNumber(Split(Split({Database.fieldname}," ")[2],":")[1]) - ToNumber(Split(Split({Database.fieldname}," ")[1],":")[1]));
endhour:=(ToNumber(Split(Split({Database.fieldname}," ")[7],":")[1]) - ToNumber(Split(Split({Database.fieldname}," ")[4],":")[1]));
startminute:=(ToNumber(Split(Split({Database.fieldname}," ")[2],":")[2]) - ToNumber(Split(Split({Database.fieldname}," ")[1],":")[2]));
endminute:=(ToNumber(Split(Split({Database.fieldname}," ")[7],":")[2]) - ToNumber(Split(Split({Database.fieldname}," ")[4],":")[2]));

if (startminute+endminute) >=60
Then
(
Finalhour:=(starthour+endhour)+1;
Finalminute:=(startminute+endminute)-60
)
else
(
Finalhour:=(starthour+endhour);
Finalminute:=(startminute+endminute)
)
;

Finalhour&":"&Finalminute