Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Leave Entitlement Calculation

Author  Topic 

micnie_2020
Posting Yak Master

232 Posts

Posted - 2013-06-10 : 23:57:17
Hi Sir,

I got table below:-
Create table testLeave
(
UserID varchar(4),
DateJoin Datetime null,
LeaveType varchar(3),
[Start_Date] Datetime null,
EnDate Datetime null,
LeaveBFDate_End Datetime null,
startday int null,
rulesincrementyr int null,
increday int null,
maxday int null
)
insert into testLeave ('A001','01/Aug/2008','ANN','01/Apr/1990','31/Mar/1991','30/Jun/1991',10,'2','2','18')
insert into testLeave ('A002','01/Feb/2009','ANN','01/Apr/1990','31/Mar/1991','30/Jun/1991',10,'2','2','18')
insert into testLeave ('A003','01/Mar/2013','ANN','01/Apr/1990','31/Mar/1991','30/Jun/1991',10,'2','2','18')

Create LeaveEntitlement
(
UserID varchar(4),
LeaveType varchar(3),
LeaveYr DateTime null,
EntitlementDay float null,
BFDay float null,
ForfeitDay float null
LeaveTaken float null
)


How to create the SP to populate the LeaveEntitlement for each fiscal year, Join Date 2 year get 2 day add on leave from startday but Max only up to 18? Example my fiscal year set on the testLeave is 01/Apr ~ 31/Mar each year. The SP will trigger on 01/Apr every year @ morning 12.01am based on local timezone.


Example output for LeaveEntitlement:-
UserID, LeaveType, LeaveYr,EntitlementDay, BFDay, ForfeithDay, Leave Taken

A001,ANN,01/Apr/2008,ProrateCalculation(DateJoin '01/Aug/2008'),0,0,3
A001,ANN,01/Apr/2009,10,?,?,null
:
:





Please advise.

Thank you.



visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-06-11 : 01:23:04
do you've a calendar with fical year values setup? Also didnt understand what you mean by
Join Date 2 year get 2 day add on leave from startday but Max only up to 18

can you illustrate with an example?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page
   

- Advertisement -