Hi Descarre and welcome
First, here are a few facts that we can use to achieve a solution
1) DatePart is a function that can be used to find out all sorts of info about a datetime value
2) The WeekDay number for saturday and sunday are 7 and 1 respectively
so we can use that to return all of the records for those days.
3) The Hour part + (the minute part/100) will give us a decimal number
we can use that to return the data between the times you want
4) The Month function returns the month number
we can use that to return the data for a particular month
Using those facts, here is one way of achieving what you want
-
select DateTime,FieldValue
-
FROM
-
( select DateTime,
-
(datepart(hh,datetime)*1.0)+(datepart(mi,DateTime)/100.0) as T,
-
FieldValue,
-
datepart(dw,DateTime)as d
-
from YourTable
-
)a
-
WHERE (d=1 or d=7 or T>=21.3 or T<=8.3) and Month(DateTime)=1
-
Oh, by the way, I don't think its a good idea to name a field the same as a data type. It might be a little confusing if you need to debug your query in 6 months time.