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 |
|
JCirocco
Constraint Violating Yak Guru
392 Posts |
Posted - 2009-08-28 : 10:44:38
|
| I am trying to take the transaction date for the last year and create a calculated value that concatenates the year, a "/" and the month# so that I can drop them into 12 buckets. the format needs to look like:yyyy/mmI have tried:Char(DATEPART(year, Rn_Create_Date)) + '/' + Char(DATEPART(month, Rn_Create_Date))but is returns NULLDoing just DATEPART(year, Rn_Create_Date) does return the 2009John"The smoke monster is just the Others doing barbecue" |
|
|
vijayisonly
Master Smack Fu Yak Hacker
1836 Posts |
Posted - 2009-08-28 : 10:48:46
|
this?select convert(varchar(7),Rn_Create_Date,111) |
 |
|
|
JCirocco
Constraint Violating Yak Guru
392 Posts |
Posted - 2009-08-28 : 10:56:02
|
| vijayisonly,Exactly! I guess I need to read up on Convert and its arguments...Thanks.John"The smoke monster is just the Others doing barbecue" |
 |
|
|
JCirocco
Constraint Violating Yak Guru
392 Posts |
Posted - 2009-08-28 : 10:58:42
|
| What threw me was the varchar(7). I didn't know you could truncate the result. So simple...John"The smoke monster is just the Others doing barbecue" |
 |
|
|
cat_jesus
Aged Yak Warrior
547 Posts |
Posted - 2009-08-28 : 10:58:52
|
| Yes, BOL has a really good writeup on convert. I'ts probably one of my most frequently referenced pages.An infinite universe is the ultimate cartesian product. |
 |
|
|
|
|
|