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
 General SQL Server Forums
 New to SQL Server Programming
 DatePart

Author  Topic 

Thiyagu_04
Starting Member

37 Posts

Posted - 2010-01-27 : 08:11:21
Hi all
using datepart i am getting following result.
Select Datepart("week", '12/27/2009')
Out put - 53
Select Datepart("week", '01/01/2010')
Out put - 1

Instead of this i want continues week number for two given dates.

Thanks for the help

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2010-01-27 : 08:35:18
the datepart(week, <date>) for 1st day of the year is always 1.

Are you looking for ISO Week ?
see http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=64762&SearchTerms=ISO%20Weeks


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-01-27 : 10:55:34
quote:
Originally posted by Thiyagu_04

Hi all
using datepart i am getting following result.
Select Datepart("week", '12/27/2009')
Out put - 53
Select Datepart("week", '01/01/2010')
Out put - 1

Instead of this i want continues week number for two given dates.

Thanks for the help


what do you mean continuos number? can you explain that
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2010-01-28 : 00:23:18
quote:
Originally posted by Thiyagu_04

Hi all
using datepart i am getting following result.
Select Datepart("week", '12/27/2009')
Out put - 53
Select Datepart("week", '01/01/2010')
Out put - 1

Instead of this i want continues week number for two given dates.

Thanks for the help


What happens if you have dates back to 2008?

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

Thiyagu_04
Starting Member

37 Posts

Posted - 2010-01-28 : 00:45:30
Continues Number in the sense
i am having From date and To date.

eg:
From date as 12/28/2009
To date as 01/27/2010

(12/28,12/29,12/30,12/31,01/01,02/01) - weekid 1
(03/01-09/01) - weekid 2
and so on

like this i want.


Hi madivanan
If 2008 is selected that would my first week.
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2010-01-28 : 01:02:15
Looks like ISO week to me. Did you check out the link i posted ?

And what is the week value if the from /to date is like
From date as 11/12/2009
To date as 01/18/2010


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

Thiyagu_04
Starting Member

37 Posts

Posted - 2010-01-28 : 01:04:56
quote:
Originally posted by khtan

Looks like ISO week to me. Did you check out the link i posted ?


KH
[spoiler]Time is always against us[/spoiler]





I am using SQL 2000
Is it possible to use ISO week
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2010-01-28 : 01:07:15
quote:
Originally posted by Thiyagu_04

quote:
Originally posted by khtan

Looks like ISO week to me. Did you check out the link i posted ?


KH
[spoiler]Time is always against us[/spoiler]





I am using SQL 2000
Is it possible to use ISO week




then use the functions provided there


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

Thiyagu_04
Starting Member

37 Posts

Posted - 2010-01-28 : 04:45:46
Thanks for All

Using Datepart and case statement i have solved this problem.

Regards
Thiyagu_04
Go to Top of Page
   

- Advertisement -