Specify Shift Hours for Tag Historian Data (Reporting)

Hello.

I am using the tag historian.. duration on value to display machine downtime between my parameters {startdate} -7days and {enddate} now. However, I need to omit the duration if it is during offshift hours. How would I go about collecting the duration value only during when the shift is active over a 7 day period? (6PM - 6AM)

Thank you.

Multiple queries. Typically an outer query that produces precise start and end timestamps for each shift, one row per shift. Then a nested historian query that references the outer row's timestamps to be its boundaries.

Hello

Can you please show this using an example?