I have a table in postgres with 2 columns; ordered_timestamp, weekday_hours.
I want to create a third column 'due_timestamp' which is calculated using 'ordered_timestamp' plus 'weekday_hours' ...BUT excluding the hours that fall across the weekend (12:00am Sat to 12:00am Mon)
ordered_timestamp | weekday_hours | due_timestamp
2020-06-04 16:00:00 | 12 | 2020-06-05 04:00:00
2020-06-05 16:00:00 | 48 | 2020-06-09 16:00:00
Without the caveat of excluding weekend hours, I could use ordered_timestamp + interval '1 hour' * weekday_hours
weekday_hours can vary from 1hr to hundreds of hours in some cases.
It seems this situation needs something additional to filter out the weekend hours.