Jump to content

Conditional Date Calculation. . .


This topic is 5521 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Here you go :(

I have a calculation that give me the "Period of employment" of each staff member using the current date and their respective start date. The result is displayed like this : 1 Year , 3 Months , 10 Days.

Now, I want to calculate their " Accumulated Vacation during their POE". The thing is . . . for the first 4 years, they get 10 Vacation days per year. After 5 years they get 15 days of vacation per year.

What do I have to add so my formula calculate the first 4 years @ 10 days per years and then 15 days per year for the subsequent ?

Also, I want my formula to add the Vacation days every months. . .

Here what I got so far:

GetAsNumber(Year(Current_Date) -

Year(Start_Date) - Case(Current_Date <

Date(Month(Start_Date); Day(Start_Date); Year(Current_Date)); 1; 0))*10 +

GetAsNumber(Mod(Month(Current_Date) -

Month(Start_Date) + 12 - Case(Day(Current_Date) <

Day(Start_Date); 1; 0); 12))* (10/12)

Link to comment
Share on other sites

I haven't tested this, but I believe it would be a simple adjustment:


Let ( [

today = Get (CurrentDate) ;

months = 12 * Year ( today ) + Month ( today ) - 12 * Year ( Start_Date ) - Month ( Start_Date ) - ( today < Date ( Month ( today ) ; Day ( Start_Date ) ; Year ( today ) ) ) 

] ;

10/12 * Min ( months ; 48 ) + 15/12 * Max ( 0 ; months - 48 )

)

It seems a bit unfair, though: employees that started working in February accumulate their vacation earlier than those that started in January, for example.

Link to comment
Share on other sites

The formula seem to work great ! Thanks a lot again for your kind help. In my original one I was counting the months separately, but I don't think it make much difference . . .

I don't get your observation about the idea that employee that start working in February accumulate their vacation earlier than in January. Are you saying that because it's now Month based instead of yearly based ?

Also I would like to add a field that trigger the calculation to be done at 10 days for the first 4 years like in your formula (that would be the (option 1) or straight at 15 days per year (option 2)

What do you recommend ?

Link to comment
Share on other sites

Are you saying that because it's now Month based instead of yearly based ?

Well yes - if you started on January 1, you'll get your first 10/12 days of vacation after working for 31 days; your co-worker that started a month later gets the same after 28 days. It evens out eventually.

I am not sure what you use this for and why do you need "to add a field that trigger the calculation". If the calculation is set to unstored, it will be correct at all times.

Link to comment
Share on other sites

This topic is 5521 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.