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 |
kpgraci
Yak Posting Veteran
68 Posts |
Posted - 2010-09-16 : 16:26:31
|
Hi all,Perhaps a little odd, but...I need to return a unique list of date parts, like the year or month, from a set of records.So for example if I have a record with fields: name, date, etcjohn, 12/31/2009, somedatafred, 2/15/2010, somedatasam, 5/21/2010, somedataI would get back:Year20092010and also (in another query for year 2010)Month25Possible?If not, I know I can add these fields in the db as Year, Monthand then query with DISTINCT. Even if there were a way to do what I want, would this second method be better for query performance (at the expense of data size)?Thanks,kpgkpg |
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2010-09-16 : 16:39:13
|
month(your_dateColumn)year(your_dateColumn)are your friends No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
kpgraci
Yak Posting Veteran
68 Posts |
Posted - 2010-09-16 : 17:35:05
|
quote: Originally posted by webfred month(your_dateColumn)year(your_dateColumn)are your friends
That's it. Thanks!kpg |
 |
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2010-09-17 : 03:16:41
|
welcome  No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
|
|
|
|