• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 304
  • Last Modified:

SELECT data by day of week

Assuming that I have a table with a date value (mm/dd/yyyy) in one of the fields, how can I select records from that table based on the day of the week?  So, if I wanted to get all records that occured on a Tuesday for example.
0
Ashley Bryant
Asked:
Ashley Bryant
1 Solution
 
Jim HornMicrosoft SQL Server Developer, Architect, and AuthorCommented:
SET DATEFIRST 1  -- Set first day of week to Monday

SELECT *
FROM YourTableName
WHERE DATEPART(dw, YourDateField) =4    
0
 
Ashley BryantSenior Software EngineerAuthor Commented:
So simple...

Thanks for keeping me humble, hehe.
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now