Forum Discussion
Anonymous
7 years agoNot applicable
Add DateTime excluding weekends
Hi, I am trying to add a new column to create a Due Dates for the Ticket Created Date. But I have to exclude weekends. No idea on how to proceed. Below is my requirement. Columns: Ticket ID, Pr...
- 7 years ago
Anonymous Please try this as a New Column. Let me know how it goes and if it fails for any of your scenario. It will be always helpful if you can post some sample test data along with the expected output.
DueDate = VAR _P1 = Test274DateAddExcludeWeekends[CreatedDate] + TIME(2,0,0) VAR _P2 = Test274DateAddExcludeWeekends[CreatedDate] + TIME(8,0,0) VAR _P3 = Test274DateAddExcludeWeekends[CreatedDate] + 7 VAR _PreFinal1 = SWITCH(Test274DateAddExcludeWeekends[Priority],1,_P1,2,_P2) VAR _PreFinal2 = SWITCH(WEEKDAY(_PreFinal1,2),6,_PreFinal1+2,7,_PreFinal1+1) VAR _Final = IF(ISBLANK(_PreFinal2),_PreFinal1,_PreFinal2) RETURN IF(Test274DateAddExcludeWeekends[Priority] IN {1,2},_Final,_P3)
Anonymous
7 years agoNot applicable
PattemManohar Yes exactly. The first soloution worked perfectly for the Incident Ticket SLA. But now for Service Request ticket SLA we have to add P2 Created Date + 10 Days. But the weekends are not getting excluded. Please help..
PattemManohar
7 years agoCommunity Champion
Anonymous Thanks for confirming that. Here is the new logic considering the change to priority2 (adding 10 days excluding the weekends)
DueDateNew = VAR _P1 = Test274DateAddExcludeWeekends[CreatedDate] + TIME(2,0,0) VAR _P2 = Test274DateAddExcludeWeekends[CreatedDate] + 14 VAR _P3 = Test274DateAddExcludeWeekends[CreatedDate] + 7 VAR _PreFinal = SWITCH(WEEKDAY(_P1,2),6,_P1+2,7,_P1+1) VAR _Final = IF(ISBLANK(_PreFinal),_P1,_PreFinal) RETURN SWITCH(Test274DateAddExcludeWeekends[Priority],1,_Final,2,_P2,3,_P3)
Note - In the above screenshot, DueDate is old logic and DueDateNew is the updated new logic.