Spllitting the calender dates

Hi,

Hi when the employes are appling for long leave based on from date to date, I need to check the from date and to date periods in this middle of this period which date is open/close I need to check(table:Workcalenderdate, field:worktimecontrol,transdate) if they give fromdate as 2-Feb-2012 to 8Feb-2012 I need to split this dates based on continues open dates like 2-Feb-2012 to 3-Feb-2012 is one line and 6-Feb-2012 to 8-Feb-2012 is one line I need to skip the 4th & 5th dates because they are closing dates. Plese help me to close this issue. Regards | sreenatha reddy.

Hi srinath,

I am also facing same problem ,if you find any solution please tell me.its urgent for me

regards,

nivas

Hi Nivas check below code process it may work to you.

void Splittingdates(EmplId _emplId,TPLLeaveCode _leaveCode,FromDate _fromDate,ToDate _toDate,TransDate _transDate)
{
Transdate rdate; // check next date
TransDate fdate; // From date for record
Transdate tdate; // To date for record
;
calenderId = emplTable::find(_emplId).CalendarId;
rdate = datenull();
tdate = datenull();
fdate = _fromDate;

for(rdate = _fromDate; rdate <= _toDate; rdate++)
{
if(this.CheckPeriodOpen(calenderId,rdate))
{
if(fdate)
tdate = rdate;
else
{
fdate = rdate;
tdate = rdate;
}
}
else
{
if(fdate && tdate)
{
leaveApplyTrans.EmplId = _emplId;
leaveApplyTrans.LeaveCode = tPLLeaves::find(_leaveCode,_emplId,true).LeaveCode;
leaveApplyTrans.FromDate = fdate;
leaveApplyTrans.ToDate = tdate;
leaveApplyTrans.ApplyDate = _transDate;
leaveApplyTrans.NoOfLeavesDays = tdate - fdate + 1;
leaveApplyTrans.insert();
tdate = datenull();
fdate = datenull();
}
fdate = rdate + 1;
}
if(rdate == _toDate && this.CheckPeriodOpen(calenderId,rdate))
{
leaveApplyTrans.EmplId = _emplId;
leaveApplyTrans.LeaveCode = tPLLeaves::find(_leaveCode,_emplId,true).LeaveCode;
leaveApplyTrans.FromDate = fdate;
leaveApplyTrans.ToDate = tdate;
leaveApplyTrans.ApplyDate = _transDate;
leaveApplyTrans.NoOfLeavesDays = tdate - fdate + 1;
leaveApplyTrans.insert();
tdate = datenull();
fdate = datenull();
}
}
}

Thanks & Regards | Srinath Reddy.