Grafana calculate only during a certain time of a day

Hey guys,

I’m working on a statistical module that displays the usage of a certain SW license.
Usage is calculated as duration of the used time divided by the total time duration that I’ve chosen & this is working fine. But what I want is that this calculation should happen only from let’s say 8 AM - 8 PM in the time range that I’ve chosen which is say last 2 weeks.

Grafana - 7.4.3
DataSource - MS SQL

Please refer the attached snapshot for SQL query& other details.
Would be great if you guys can provide some help. Let me know if you need any more details.