Separating working hours with non-working hours SQL
If I can understand what you are asking I wrote this code for you. This is when your workweek will be from monday till friday and your workhours will be from 8 to 17

select *
      from (
           select
           case when datename(dw,[date]) in ('Saturday','Sunday') then 'Weekend' else 'Week' end as WeekendOrWeek,
           datepart(HOUR,[date]) as HourDate,
           *
           from Electricalconsumptionhalfhourview
           where meterID = 17635382
           )WeekDays
where WeekDays.WeekendOrWeek = 'Week' and WeekDays.Hourdate &gt; 8 and WeekDays.HourDate &lt; 17


This is written for T-SQL. (SQL Server) If you want to get the dates which are not in the week just edit the where clause.