function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

calculate the workdays excluding weekend and/or Public Holiday In Einstein Analytics

Hi All,

I have a scenario to calculate the workdays excluding weekend and/or Public Holiday In Einstein Analytics. 

We need something like date = now()+workdays(5) that respect weekends and/or Public Holidays - ideally taken from the "Business Hours" setup. 

In "Business Hours": We insert Holidays for countries globally.

Please, can anyone help how they implemented or it can be implemented in dataflow computation field?


Gayatri Sharma
kailash chandrakailash chandra
Hi Gayatri,
write the apex as your requirement.
// Your question is like  date = now()+workdays(5) 
// This will return a Date from today and BusinessHours class will auto calculate the holiday of next n days

System.debug( BusinessHours.add('BUSINESS_HAUR_ID',, 86400000*5));

//BUSINESS_HAUR_ID : Your Business hour Id
//             : From which date you want to start
//86400000*5               : this is milliseconds in a day and 5 is next 5 days

//public static Datetime add(String businessHoursId, Datetime startDate, Long intervalMilliseconds)

Please create different holidays in your org as you want and add these holidays to your business hour.
see in screenshot
User-added image
User-added image

I hope this will help you.

Kindly mark this as solved if the reply was helpful.

Kailash Chandra
Hi Kailash, This is a nice explanation provided by you, thanks. I need to do this calculation in Einstein Analytics dataflow, I am not able to understand how to implement the same in the dataflow. Dataflow has nodes which are basically SFDC tables/objects. I have taken work order and business hours table. I am able to join these two tables using business hours ID. I have to evaluate one date field where I will add three days. the outcome date should exclude the weekends and holidays. As a workaround, I can make one formula field for same calculations on work order and fetch that date field in my dataflow. Please, can you help me in some way so I don't need apex code and can get the value in the formula field?
Gayatri Sharma