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.
| Author |
Topic |
|
mrm23
Posting Yak Master
198 Posts |
Posted - 2010-07-20 : 02:44:12
|
| Hi All,I have to make a report for which i have sales on y-axis and weeks on x-axis.For the x-axis data i need to use a datetime column in my table.Now, how can i segregate the entire column as weeks ?Let me know if more info is required.thanks,malavika. |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2010-07-20 : 02:46:31
|
Post some sample data and the expected result KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
mrm23
Posting Yak Master
198 Posts |
Posted - 2010-07-20 : 02:58:42
|
| Hi khtan,thanks for the reply.my time column in DB has time in seconds like : time_uploaded2009-05-31 23:13:09.1402009-05-31 23:13:26.2402009-05-31 23:13:58.3972009-05-31 23:14:09.1432009-05-31 23:14:20.177there are over a million such rows.I must now break them into weeks. if my table has one year's data then i will get 52 weeks.All these 52 weeks are plotted on x-axis and the sales for each week will be plotted on y-axis.My ques is how can i convert this column into so many no. of weeks? |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2010-07-20 : 03:12:01
|
you can use datepart(week, time_uploaded) to get the week no KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
mrm23
Posting Yak Master
198 Posts |
Posted - 2010-07-20 : 04:33:31
|
| hi,sorry may be i was not clear of what i needed. this gives me the number of weeks. for example if i run the above select statement i am getting 23.but then how will i mark these on graph? since this will be used for a chart report in report builder, i want it to show the 23 weeks separately. For this should i need the date range instead? (like 1st-Jan to 8th-Jan) how to get that? |
 |
|
|
|
|
|