I want to create a custom formula in Transform node of Data prep recipe that calculates weekdays between two dates. I just don't seem to find a function that tells day of the week from a date. Any suggestions?
Eric Praud (Activ8 Solar Energies) Forum Ambassador
Hi Ravi,
Not sure I understand. Do you want to see the amount of days between 2 dates without weekends, or do you want a formula to show the name of the day of the week for each date?
If the former:
EndDate__c-StartDate__c-
(
FLOOR((EndDate__c - StartDate__c)/7)*2
+
IF(AND(WEEKDAY(StartDate__c )=1, WEEKDAY(EndDate__c )<>7),1,
IF(CASE(WEEKDAY(StartDate__c ),1,8,WEEKDAY(StartDate__c ))>CASE(WEEKDAY(EndDate__c ),1,8,WEEKDAY(EndDate__c )),2,
IF(OR (WEEKDAY(EndDate__c )=7, WEEKDAY(StartDate__c )=1),1,
IF(OR (WEEKDAY(EndDate__c )=1, WEEKDAY(StartDate__c )=7),2,
0)))))
If the latter:
IF(ISBLANK(DateField__c), NULL,
CASE(
WEEKDAY(DateField__c),
1, "Sunday",
2, "Monday",
3, "Tuesday",
4, "Wednesday",
5, "Thursday",
6, "Friday",
"Saturday"
))
And make sure you select "Treat blank fields as blank"