Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Week Formula

Status
Not open for further replies.

strom99

MIS
Nov 28, 2000
126
US
Hi

Have the following field cut_date and I need to include another field that will tell me which week (date) it occured. So if it the cut_date was 09/17/03 I would need another column to tell me that it occured during the week of 09/15/03.

Thanks much!
 
Try this:

DECLARE @querydate DATETIME
SET @querydate = '2003-09-17'
SELECT DATEADD(DAY,(DATEPART(DW,@querydate))-(@@DATEFIRST)), @querydate)

If it doesn't return the proper day, do this
SELECT @@DATEFIRST

The result should be 1 if it's set to show MONDAY as the first day of the week.

-SQLBill
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top