Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Date within a week using week number

Author  Topic 

vk59
Starting Member

38 Posts

Posted - 2006-08-28 : 08:37:31
Hi all,
HI all,
Is there a query to get the dates in a week range. When I pass week number and Year as input it should return all dates in the particular week.
For e.g:
If I pass 34 as weeknum and 2006 as year , it should return dates from Aug 20th to Aug 26th


Thanks in advance
Vk59


`

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2006-08-28 : 08:42:56
Use this function http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=61519 and call with select * from F_TABLE_DATE where year = 2006.

Also, what defines "Week 1"?


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2006-08-28 : 08:51:23
Maybe this will do?
SELECT	DATEADD(day, -7 + 7 * 34, '2006-01-01'),
DATEADD(day, -1 + 7 * 34, '2006-01-01')


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)

7020 Posts

Posted - 2006-08-28 : 09:54:55
You have to define when the first week of the year starts before we can help you. Different organizations use different rules to define the "week of ywar".

For example:
Does it start on Jan 1?
Does it start on the first Sunday of the year?
Does it start on the first Sunday on or before Jan 4 of the year?
Some other rule?





CODO ERGO SUM
Go to Top of Page

vk59
Starting Member

38 Posts

Posted - 2006-08-29 : 00:09:45
Thank you very much

`
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2006-08-29 : 00:55:42
God bless you and have mercy on your soul!


Peter Larsson
Helsingborg, Sweden
Go to Top of Page
   

- Advertisement -