Question:
Formula:
start date + adddays = enddate
Actual output: 14/12/2023 + 3days = 19/12/2023Appreciate if anyone can guide the method to calculate the enddate and avoid the weekend?????Thank youuu
Hi JW L,
Please refer to this post. Hope this helps.
https://www.outsystems.com/forums/discussion/45772/how-to-add-days-to-date-excluding-weekends/
Regards,
Wasimkhan S
Hi,
Consider using a Forge component that already implemented that logic for your:
https://www.outsystems.com/forge/component-overview/11440/working-days-reactive
Daniel
Hi jwl , I done one logic and sample output is I attched the OMl file, please refer it.
Appreciate of your help. I have created the calculation client action but I'm facing the issue now which is I don't know how to loop the client action row by row based on different adddays but same start date in table. Do you know how to do this? If yes, please guide me~~~~I'm able to calculate when adddays is 5. How about if I change the adddays to 3days and enddate should be 15/12/2023.I put this client action in on change action of input startdate.How to loop this client action to calculate the different SLA and same startDate in table above?
Sure,1. Set as function to used client Action.2. Used client action in Expression in your tableI hope its helpful.
The sample output is I attached the oml for your reference, kindly refer it
Hi @JW L
Please consider the below mentioned code:
var startDate = "9-DEC-2011";startDate = new Date(startDate.replace(/-/g, "/"));var endDate = "", noOfDaysToAdd = 13, count = 0;
while(count < noOfDaysToAdd){ endDate = new Date(startDate.setDate(startDate.getDate() + 1)); if(endDate.getDay() != 0 && endDate.getDay() != 6){ //Date.getDay() gives weekday starting from 0(Sunday) to 6(Saturday) count++; }}alert(endDate);
OR
You can try with advance sql also -
Pass two parameters @MyDate ,@MyDays and define a structure of type Date and execute the below query
SELECT DATEADD(d , (@MyDays / 5) * 7 + (@MyDays % 5) + (CASE WHEN ((@MyDays%5) + DATEPART(dw, @MyDate)) IN (1,7,8,9,10) THEN 2 ELSE 0 END) , @MyDate) AS Date
Thanks
Himani
You copied the javascript from this reply:
https://www.outsystems.com/forums/discussion/45772/how-to-add-days-to-date-excluding-weekends/#Post166785
and the SQL from this reply:
Better to just share the replies, instead of pretending it is your solution.
Furthermore, the discussion from which you copied this, was already shared on the first reply of this discussion, so totally unnecessary to share again.
Hi
I didn't provide a link because there were multiple suggestions, and my intention was to save time and help more directly.
I shared the solution directly in the code instead of providing a link because I wanted to be specific and efficient in helping. Knowing that anyone can easily search and find the source if needed.
Given that exactly these 2 replies were marked as solution, there is no need to do that.
Furthermore, if you do, following the community guidelines, you could mention the source.
Hi @JW L ,
Did you get the solution? if not ! Here is the forge use this, logic is written there kindly go through that .
Demo - Try
Forge - Day calculation
Hope this will help you!
Kind regards
Sourabh Sharma