Skip to main content
Ravi Deshmukh が「#Sales Cloud」で質問

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?

 

#Sales Cloud  #Analytics

12 件の回答
  1. Eric Praud (Activ8 Solar Energies) Forum Ambassador
    2021年10月1日 13:12

    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"

0/9000