crystal reports claculating time difference
i am calculating the time differrence for employees betweeen the actual swipetime and the schedule time
I want to calcualte the difference in "HH:mm:ss" for employees who are late and also for employees who report early
so i ahve written the formula in crystal reports
the following is for "TimeIN" difference
considering The start time to be at 7:30 am and EndTime At 3:30 pm
local TimeVar t1 := Time({EmployeeSchedule.StartTime});
local timeVar t2 := Time({EmployeeAttendance.Time});
local Datevar d1 := Date({EmployeeAttendance.Time});
IF IsTime(Cstr(t2)) AND {EmployeeAttendance.Event} = 1
THEN
(
if(t2 >= t1 ) THEN
(
"*"+ToText
(
TimeValue
(
DateDiff("h",DateTime(d1,t1),DateTime(d1,t2))
,
DateDiff("n", DateTime(d1 ,t1),DateTime(d1,t2))
,
0
)
,"HH:mm:ss")
)
for the abopve code works only if the employee is late and not if the employee reports early
I am getting correct answer for the "TimeIN" but not for "TimeOUT"
The formula for TimeOUT is follows
--------------------------------------------------------------------------
For "TimeOUT" Difference
local TimeVar t1 := Time({EmployeeSchedule.EndTime});
local timeVar t2 := Time({EmployeeAttendance.Time});
local Datevar d1 := Date({EmployeeAttendance.Time});
IF IsTime(Cstr(t2)) AND {EmployeeAttendance.Event} = 2
THEN
(
if(t2 <= t1 ) THEN
(
"*"+ToText
(
CTime
(
Hour(Ctime(DateDiff("h",DateTime(d1,t2),DateTime(d1,t1))))
,
Minute(Ctime(DateDiff("n", DateTime(d1 ,t2),DateTime(d1,t1))))
,
Second(Ctime(00))
)
,"HH:mm:ss")
)