MikeAlike234
MikeAlike234

Reputation: 759

Receive day id to use in where clause (SQL Server)

Is it possible to make a SQL Server query like this:

Select * 
From table 
Where GetDayOfWeekId(DateColumn) = 1

DateColumn has a string value like 2014-04-18

Is there a function that can extract a day name or an id to use in the where clause?

Upvotes: 0

Views: 112

Answers (2)

laggerok19
laggerok19

Reputation: 452

If I undestand you need:

Select * From table Where DATEPART(weekday,DateColumn) = 1

Upvotes: 0

Mudassir Hasan
Mudassir Hasan

Reputation: 28781

Select * From table Where DATENAME(dw,DateColumn) = 'Monday'
Select * From table Where DATEPART(dw,DateColumn) = 1

More DATE info extracting Functions

Upvotes: 2

Related Questions