Please do post your comments and suggestions for me to improve on chowdary1105@gmail.com

Sunday, August 9, 2009

Date related calucations

Local date &From_Date, &To_Dt;

&Duration = 0;
&Tot_Holi = 0;
&Sat = 0;
&Sun = 0;

&From_Dt = SRI_STUMOD_TBL.SRI_STUAB_STD.Value;
&To_Dt = SRI_STUMOD_TBL.SRI_STUAB_END.Value;

While (&From_Dt <= &To_Dt);
&From_Dt = AddToDate(&From_Dt, 0, 0, 1);
If (Weekday(&From_Dt) = 7) Then
&Sat = &Sat + 1;
End-If;
If (Weekday(&From_Dt) = 1) Then
&Sun = &Sun + 1;
End-If;
If Weekday(&From_Dt) <> 7 And
Weekday(&From_Dt) <> 1 And
&flag <> "x" Then
&Duration = &Duration + 1;
End-If;

SQLExec("select 'x' from PS_HOLIDAY_DATE WHERE HOLIDAY=:1", &From_Dt, &flag);
If &flag = "x" Then
&Tot_Holi = &Tot_Holi + 1;
End-If;


End-While;
SRI_STUMOD_TBL.SRI_STUAB_SAT.Value = &Sat;
&Sat = 0;
SRI_STUMOD_TBL.SRI_STUAB_SUN.Value = &Sun;
&Sun =0;
SRI_STUMOD_TBL.SRI_STUAB_DURATION.Value = &Duration;

No comments: