You're almost there! Please answer a few more questions for access to the Applications content. Complete registration
Interested in joining? Complete your registration by providing Areas of Interest here. Register

date_add but only weekdays

Question
15
Views
0
Comments

Summary

Want to use date_add, but only using weekdays

Content

We have a variable that adds different numbers of days to the created date depending on the category to give us an SLA date. (code below)

I've been asked if it can ignore weekends, and therefore only add weekdays. Has anyone found a way to do this?

I wondered if I could do something clever with rel_date_diff, but apparently this can't be used in variables nor nested, which rules it out.

Any other ideas?!

Version

18D

Code Snippet

date_trunc(if(incidents.c$due_date is not null,incidents.c$due_date,if(incidents.c$campaignformtype IN (1431,1573,1574,1560,1567) | incidents.source_lvl2=5001,date_add(incidents.created,2,DAYS,0),  if(incidents.cat_id IN (127,1100,259,1070,1076,1074,1075,1072,1069,1067,1071,1068,1073,325,322,167,286,93,66,615,711,1029,184,392,393,394,51,718,969,961,978,70,1090,1089,1091,1088,1087,125,560,1007,330,950,131,258,1691,624,996,426,305,425,913,919,687,697,268,272,74,865,266,583,267,186,589,0,1011,971,972,898,780,793,995,991,989,128,675,1052,315,581,582,73,67,55,53,54,1020,1019,264,954,65,347,573,1051,171,71,691,934,970,366,367,130,438,365,52,1056,678,92) | incidents.cat_id is null, date_add(incidents.created,1,DAYS,0),if(incidents.cat_id IN (958,579,634,635,729,332,284,617,658,734,285,283,84,727,578,122,123,81,244,296,277,876,275,210,245,144,323,1043,37,685,1018,178,993,1097,428,36,321,811,39,75,587,72,237,726,1096,967,683,909,925,684,990,608,320,576,580,720,246,1022,1049,126,24,80,152,119,745,1017,570,135,877,722,905,926,326,572,861,192,118,730,713,986,1001,348,1021,1050,611,677,710,276,654), date_add(incidents.created,2,DAYS,0),if(incidents.cat_id IN (575,666,132,312,668,890), date_add(incidents.created,3,DAYS,0),if(incidents.cat_id IN (3646,2452), date_add(incidents.created,4,DAYS,0),if(incidents.cat_id IN (792,472,1028), date_add(incidents.created,5,DAYS,0),if(incidents.cat_id IN (1085,437,869), date_add(incidents.created,7,DAYS,0),if(incidents.cat_id IN (301,895), date_add(incidents.created,10,DAYS,0),if(incidents.cat_id IN (260), date_add(incidents.created,15,DAYS,0),if(incidents.cat_id IN (1048,1046,1044,1045), date_add(incidents.created,23,DAYS,0)))))))))))),DAYS)

Howdy, Stranger!

Log In

To view full details, sign in.

Register

Don't have an account? Click here to get started!