Sunday, March 11, 2012

Cumulative weeks

SQL Server 2000 SP3

Hi,

How can I get the cumulative weeks from a givedate to the current
date. I know I can get the weeknumber by using datepart(wk,getdate())
but this will give
me the week number for this year. What if I want to know the number of
weeks
that have passed since june 1 2001. If I use datepart(wk,'20010106') I
will
get the week number for 2001 but I would like the number of weeks
expired between then now.

Thanks,
RegOn 2 Sep 2004 10:01:12 -0700, Sam wrote:

>SQL Server 2000 SP3
>Hi,
>How can I get the cumulative weeks from a givedate to the current
>date. I know I can get the weeknumber by using datepart(wk,getdate())
>but this will give
>me the week number for this year. What if I want to know the number of
>weeks
>that have passed since june 1 2001. If I use datepart(wk,'20010106') I
>will
>get the week number for 2001 but I would like the number of weeks
>expired between then now.
>Thanks,
> Reg

Hi Reg,

select datediff(week, '20010106', getdate())

----
191

By the way - '20010106' is january 6, not june 1...

Best, Hugo
--

(Remove _NO_ and _SPAM_ to get my e-mail address)

No comments:

Post a Comment