Using DatePart to show specific Days

Is it possible to use the DatePart function to show a Week running from Sat - Fri as opposed to your typical Monday - Sunday week? I know this will return Monday - Sunday, but can ya change it to Sat - Wed?

DATEPART(WEEK,[HireDate]) AS Week_Number

Upvotes: 0

Views: 64

Answers (3)

Biri
Biri

Reputation: 7181

You can change the first day of week with datefirst.

set datefirst 6

Datepart week and weekday will work according. Check http://msdn.microsoft.com/en-us/library/ms174420.aspx for more details.

Upvotes: 1

Hart CO
Hart CO

Reputation: 34784

You can alter the first day of the week:

SET DATEFIRST { number | @number_var } 

Upvotes: 1

Stephen Turner
Stephen Turner

Reputation: 7314

Yes use SET DATEFIRST this sets the day to count as the first day of the week so it changes on the day you specify.

Upvotes: 4

Related Questions