Link to home
Start Free TrialLog in
Avatar of craigdev
craigdev

asked on

Week part

I have a sql query that groups on "Datepart(dw, DateField)" however in some cases the week should start of a Thrusday and end on the following wednesday. What is the best way to handle a week not starting on a Sunday?



Avatar of gjutras
gjutras

write a scaler function that returns the week number you want and use that in your select and group by.  use a case or if statement in the function to adjust the date based on start of week day.  Let me know if you'd like help with a function to do that.
ASKER CERTIFIED SOLUTION
Avatar of gjutras
gjutras

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial