Hello,

I have a Table in SQL DB called VNewEntries and the columns are: ID, EmpNo, AppointmentDate, VFrom, VTo, VBasicSalary, VAllowances, DeservedBalanceDays, DeservedBalanceKD.

What I want is to check if the AppointmentDate is between VFrom and VTo and do some calculation to get the DeservedBalanceDays then another calculation to calculate DeservedBalanceKD.

For Example:

Employee has EmpNo 3 and his AppointmentDate is 2018-02-15
VFrom is 2018-02-01
VTo is 2018-02-28
DeservedBalanceDays will be VTo - AppointmentDate +1
DeservedBalanceKD will be (DeservedBalanceDays / 26) * (VBasicSalary + VAllowances)

This will be if the AppointmentDate is between VFrom and VTo, if not he will get 2.5 in DeservedBalanceDays.

Thanks in advance.