Forum Discussion
Day shift and night shift
ivannye , Try two new columns like
Duration Night =
Switch(true() ,
Hour([StartTime]) <= 21 && Hour([EndTime]) >=21 , datediff(date(year([start time]), month([start time]), day([start time])) + time(21,0,0), [Endtime], second),
Hour([StartTime]) <= 7 && Hour([EndTime]) >=7 , datediff([start time], date(year([Endtime]), month([Endtime]), day([Endtime])) + time(7,0,0), second),
datediff([start time], [Endtime] , second)
)
Duration Day =
Switch(true() ,
Hour([StartTime]) <= 21 && Hour([EndTime]) >=21 , datediff([start time], date(year([Endtime]), month([Endtime]), day([Endtime])) + time(21,0,0), second) ,
Hour([StartTime]) <= 7 && Hour([EndTime]) >=7 ,datediff(date(year([start time]), month([start time]), day([start time])) + time(7,0,0), [Endtime], second),
datediff([start time], [Endtime] , second)
)
Thank you for your reply. above you wrote starttime and endtime. do you mean start_time and end_time?
- amitchandak5 years ago
Super User
ivannye , yes, You start_time and End_time columns. Please choose the column's name as in your file. Diff is in seconds
- ivannye5 years ago
Helper I
Thank you. Here is the result below.
As you can see the solution on both column duration_day and duration_night are the same. durationday and durationnight are manual calculations