[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

SQL determine WeekNo of a date.

Posted on 2011-05-03
3
Medium Priority
?
216 Views
Last Modified: 2012-05-11
Hello
I am looking to determine what week of the year a date falls in.
what I am running into is Sunday appears to be calculated as first day of the week
is there a way I can change this to Monday being first day of the week  as we search for transactions on the work week monday to sunday.

right now if i want to search for data 10 wks ago based on beginning and ending dates
ex: 04-25-2011 to 05-01-2011, 05-01-2011 is sunday and is a diff week no than 04-25-2011
0
Comment
Question by:schuitkds
  • 2
3 Comments
 
LVL 32

Expert Comment

by:Ephraim Wangoya
ID: 35513035


select datename(week, getdate())
0
 
LVL 32

Expert Comment

by:Ephraim Wangoya
ID: 35513043

To change srtart of week to Monday you can use

SET DATEFIRST 1  --Monday
0
 
LVL 4

Accepted Solution

by:
Kalyanum Deepak Kumar earned 2000 total points
ID: 35704503
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
An alternative to the "For XML" way of pivoting and concatenating result sets into strings, and an easy introduction to "common table expressions" (CTEs). Being someone who is always looking for alternatives to "work your data", I came across this …
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Via a live example, show how to setup several different housekeeping processes for a SQL Server.
Suggested Courses

872 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question