Skip to Content
0
Former Member
Dec 15, 2009 at 04:06 PM

Using Command for Charting

9 Views

Hi Guys,

I need some help.

I created the following query below:

The #weektable acts as the LEFT most table in a big query. Basicaly this query is thrown into a CR report and used for charting. The graph shows 4 weeks, last week, this week, next week, and two weeks from now.

However, if you run the query below, you'll notice that two weeks from now returns Week # 53 when it should be Week # 1 for the beginning of the new year.

Can anyone please please help me figure this out? Thank you in advance.

SELECT DATEPART(YEAR,getdate()) AS 'Year', 
       DATEPART(wk,getdate())-1 AS 'Week #'  into  #weektable 
 insert  into #weektable 
SELECT DATEPART(YEAR,getdate()) AS 'Year', 
       DATEPART(wk,getdate()) AS 'Week #' 
 insert  into #weektable 
SELECT DATEPART(YEAR,getdate()) AS 'Year', 
       DATEPART(wk,getdate())+1 AS 'Week #'  
insert  into #weektable 
SELECT DATEPART(YEAR,getdate()) AS 'Year', 
       DATEPART(wk,getdate())+2 AS 'Week #'  

Regards,

Zack H.