27
Views
10
Comments
Solved
Add 60 working days to a date
Application Type
Reactive

Hello Community,

i would like to add 60 working days to a date that I select via a date and time picker and store in an attribute. How can i do that ?

many thanks in advance

Solution

there are probably dozens of smart ways/formulas to do this, but for a beginner, I would say, 

  • make an ad hoc loop
  • start with the DistributionDate
  • in every iteration
    • add 1 day
    • check if it is a working day
    • if so, add 1 to a counter
  • if your counter reaches 60, you are there, that's the day you are looking for

With this approach, if it is really as simple as skipping saturdays and sundays, you can implement the check by looking at the DayOfWeek(xxxx) being different from 0 or 6.

Package all this in a function, and you can use it in a statement or ui expression

Dorine

can you please show me another approach, can't get it right.

Solution

Hey Tom,

I have implemented this task . I am providing you the demo OML for this.It will help you.

Thanks & Regards,

Sudip Pal 

AddingWorkingDays.oml

there is no reason really to do this in javascript

that entirely depends on your definition of working days.

Sorry working days are Monday to Friday

even christmas ?

yes,  


I have tried this: 

this also includes Saturday and Sunday.

Hello Tom, 

Try the following component: 

You might also find it interesting to explore the client and server actions inside and adapt them to your case :) 

Also, I noticed the following post: 

This is an old post, but the mathematical logic seems working fine! You might need to adapt it, but you can use the AddDays function. 

Best regards, 

Ana

Solution

there are probably dozens of smart ways/formulas to do this, but for a beginner, I would say, 

  • make an ad hoc loop
  • start with the DistributionDate
  • in every iteration
    • add 1 day
    • check if it is a working day
    • if so, add 1 to a counter
  • if your counter reaches 60, you are there, that's the day you are looking for

With this approach, if it is really as simple as skipping saturdays and sundays, you can implement the check by looking at the DayOfWeek(xxxx) being different from 0 or 6.

Package all this in a function, and you can use it in a statement or ui expression

Dorine

can you please show me another approach, can't get it right.

Hello,


My understanding in this is that we can apply filter in that particular aggregate to get the data.

Hope this will be helpful!!

Solution

Hey Tom,

I have implemented this task . I am providing you the demo OML for this.It will help you.

Thanks & Regards,

Sudip Pal 

AddingWorkingDays.oml

there is no reason really to do this in javascript

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.