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 2005 Forums
 Transact-SQL (2005)
 Need help with stored procedure

Author  Topic 

JJ297
Aged Yak Warrior

940 Posts

Posted - 2009-05-13 : 14:24:13
The table is called ClearedDiary

Fields:
doc (varchar(3), null)
totmet (int, not null)
totclr (int, not null)
weekdat (datetime, null)
dowrdat (datetime, null)

Here's my stored procedure:

Select distinct weekdat,
cast(DATEPART(m, weekdat) as Varchar(5))+'/'+
cast(DATEPART(d, weekdat) as Varchar(5))+'/'+
cast(DATEPART(yy, weekdat) as Varchar(5))as[Week]
from dbo.ClearedDiary
order by weekdat desc

I would like to have only the converted column Week returned in the results but I'm getting both columns, Weekdat and Week. Is this possible?

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-05-13 : 14:30:09
SELECT CONVERT(VARCHAR(10), WeekDat, 101) AS [Week]
FROM dbo.ClearedDiary
GROUP BY CONVERT(VARCHAR(10), WeekDat, 101)
ORDER BY WeekDat DESC


E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

JJ297
Aged Yak Warrior

940 Posts

Posted - 2009-05-13 : 14:34:01
Perfect...Thanks!
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-05-13 : 14:36:28
You're welcome.



E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page
   

- Advertisement -