Ad

Filter Query Result For Every Thursday Of A Given Month

- 1 answer

I have a SQL table with 2 columns ID (int) and CreateDate (DateTime) type. I want to filter all the IDs for each Thursday for a given month whether I pick Jan, Feb, March, etc...

Ad

Answer

If I understand correctly, DATEPART function might help you to do that.

you can use weekday in the first parameter which returns weekday from DateTime, if you want to compare others information DATEPART might help you compare.

SELECT *
FROM T
WHERE  
    DATEPART ( weekday , CreateDate ) = 5
Ad
source: stackoverflow.com
Ad