You did not give too many details, I think what you need is something like this:
SELECT SearchId, getdate() as CreateDate FROM Security.Search
WHERE DATEDIFF(DAY, CreateDate, GETDATE()) < 8 AND DATEPART(DW, CreateDate) != 7
This will pick up the last 7 days but disregard the Sunday. If you want to take 7 days in total already disregarding Sunday in the account, then change the condition < 8
to <= 8
.
The first part of the condition takes the number of days you want ( DATEDIFF
and GETDATE
) and the second part filters Sunday, which is considered to be day 7 of week obtained by DATEPART
.