Forum Discussion
ashaikh
8 years agoHelper III
Time calculation
Hello, I am looking to do some time calculation on a DateTime and would want to know if there is an easier way to do it. What I am trying to do is basically calculate SLA DueTime which is same bu...
- 8 years ago
Hi ashaikh,
Try this formula as a calculated column please.
Column = VAR currentDay = DATEVALUE ( [Date] ) VAR nextWorkDay = CALCULATE ( MIN ( 'Calendar'[Date] ), FILTER ( 'Calendar', 'Calendar'[Date] > currentDay && 'Calendar'[isWorkDay] = 1 ) ) RETURN IF ( TIMEVALUE ( [Date] ) + TIME ( 8, 0, 0 ) <= TIME ( 17, 0, 0 ), [Date] + TIME ( 8, 0, 0 ), nextWorkDay + TIMEVALUE ( [Date] ) )Best Regards,
Dale
v-jiascu-msft
8 years agoMicrosoft Employee
Hi Abdulquadir,
I'm afraid I have no idea about how to get "1: 20PM".
1. 6/28/2018 9:00 AM + 3hrs 20 mins is 6/28/2018 0:20 PM;
2. 6/28/2018 9:00 AM + 4hrs 40 mins is 6/28/2018 1:40 PM;
So how can we get 6/28/2018 1:20 PM?
Best Regards,
Dale
- ashaikh8 years agoHelper III
Yes you are right. It should be 1:40PM. So it will be 6/28/2018 1:40 PM
But the main point here which I wanted to show is SLA is 8 hrs and with in a business day so if 8 hrs is completed with in todays business date then Due Date will be next day with remaining time from start of business day i.e 8:00 am
- v-jiascu-msft8 years agoMicrosoft Employee
Hi ashaikh,
Try this formula as a calculated column please.
Column = VAR currentDay = DATEVALUE ( [Date] ) VAR nextWorkDay = CALCULATE ( MIN ( 'Calendar'[Date] ), FILTER ( 'Calendar', 'Calendar'[Date] > currentDay && 'Calendar'[isWorkDay] = 1 ) ) RETURN IF ( TIMEVALUE ( [Date] ) + TIME ( 8, 0, 0 ) <= TIME ( 17, 0, 0 ), [Date] + TIME ( 8, 0, 0 ), nextWorkDay + TIMEVALUE ( [Date] ) )Best Regards,
Dale
