PDA

Click to See Complete Forum and Search --> : crystal report calculating time difference


sayyedar
May 15th, 2007, 08:51 AM
I am calculating time difference of employees based on the TimeIN and TimeOUT against the schedule of the employee

My Time In formula works fine but only if the employee is late and not if the employee reports earlier than the scheduled time


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
//AND
//({EmployeeAttendance.EmployeeID} = {Employee.EmployeeID})
//({?ReportDate} = {EmployeeAttendance.SwipeDate}) AND
//(Month({EmployeeAttendance.SwipeDate})) = {EmployeeSchedule.MonthYear}

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")
)

_____________________________________________________________-----

my formula for TimeOut is as follows










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")
)



Do let me know the mistake i am doing