Calculate the end date(SLA) from its start date in business hours

I need to calculate end-date/SLA for a given start-date considering the completion-time in minutes within the business hours/days.

For instance :

  • start-date = 2023-03-17 15:00:00
  • completion-time = 240 (minutes)

Considering 9 working hours per day(9am to 6pm) and weekend on Saturday Sunday. The end-date should be 2023-03-20 10:00:00.

So the total hours are 4,

  • on 2023-03-17 from 15:00:00 to 18:00:00 (3 hours)
  • on 2023-03-18--- Saturday
  • on 2023-03-19---Sunday
  • on 2023-03-20 from 09:00:00 to 10:00:00(1 hour) complete sla

Any help with regards to this would be much appreciated.

So far i can able to get the total working days excluding the weekends but getting exact end time is where i'm struggling.

Thank you.