typical logic

1. Senior Member
Join Date
Dec 1969
Posts
161

## typical logic

HI friends,<BR><BR> Can u tell the logic for my problem?<BR>I am generating payslip. I have different table to store leaves, attendance,emloyee,holidays. 2 types of employees(Staff and Worker). Staff can avail 6 leaves(paid) for 6 months. It count from the date of join of emp. If he avails more than 6, excess will be deducted from the current salary. If not used, balance will be brought forward to next 6 months.(next 6 months he can avail 6+prev balance). If he didnt utilize 12(total 6+6 or 12-usedleaves), the balance is brought forward to next year. So next year first 6 months he can avail prev year balance+6. This is upto 2 years. We have to follow according to this country labour law. <BR>I think u got it. I am not able to find the logic for counting 6 months from the dateofjoin and if excess(&#062;6 in 6 months) will be deducted on the spot. So, the law states that emp can avail 6 leaves in 6 MONTHS. We have to count leaves for every 6 months from the date of join.<BR><BR>If any reply is highly appreciate. Thanx in advance.<BR><BR>U can send mail to rajani@tom.com.bn<BR><BR>

2. Senior Member
Join Date
Dec 1969
Posts
3,195

## Nobody is going to write this

for you. You have to show us you have made an attempt to solve this. ;)<BR><BR>That means showing the relevant code that is giving you a problem. <BR><BR>If you would like folks to write it for you then they would be happy to give you their PayPal account#.

3. Senior Member
Join Date
Dec 1969
Posts
288

## RE: typical logic

#1. Counting 6 months from the date of join: use the DateAdd function format DateAdd(Interval As String, Number As Double, Date)<BR><BR>DateAdd("D", 180, dateofjoin) - this will give you the target date<BR><BR>DateDiff("d", dateofjoin, currentdate) will give you the difference <BR><BR>HTH<BR>RAJ.<BR>

4. Senior Member
Join Date
Dec 1969
Posts
96,118

## Yeah, but what complicates this...

...is that if the person takes, say, 8 leaves in the first 6 months then his salary is deducted for 2 of them but then *only* those 6 carry over to next 6 months.<BR><BR>In other words, you can&#039;t say, for the second 6 months:<BR> availableLeave = 12 - leavesTakenInLastYear<BR><BR>It has to be<BR> availableLeave = 12 - leavesTakenInLastSixMonths <BR> - IIF( leavesTakenPriorSixMonths &#062; 6, 6, leavesTakenPriorSixMonths )<BR><BR>And then that logic has to continue for up to two years.<BR><BR>Really ugly.<BR><BR>I think that I would redesign the table, just a little bit. In the "Leave" table, add a field named "ExcessLeave" and make it a True/False field. When you add a new Leave to that table, if it is the 7th one or later in the current six-month period, then make that flag TRUE (otherwise false). Then, when you do your calculation for AvailableLeave, simply ignore the records where that field is True!<BR><BR>Makes the SQL query much much simpler.<BR><BR>Still not an easy query, but not as bad as it is without the extra field.<BR><BR>

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•