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 |
|
rohcky
Starting Member
38 Posts |
Posted - 2006-05-09 : 10:29:08
|
| I apologize for making another post so soon, but I'm having trouble concatenating a string after using the month and year function. Is it even possible to do that?SELECT MONTH(date) + '/' + YEAR(date) as DATEFROM tableResult: Syntax error converting the varchar value '/' to a column of data type intSELECT MONTH(date) + YEAR(date) as DATEFROM tableResult:------DATE------200120012001200220022003etc... |
|
|
Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)
7020 Posts |
Posted - 2006-05-09 : 10:53:17
|
This should do what you want:select right(convert(varchar(10),date,103),7)as DATEfrom (select date = getdate() ) aResults:DATE ------- 05/2006(1 row(s) affected) CODO ERGO SUM |
 |
|
|
rohcky
Starting Member
38 Posts |
Posted - 2006-05-09 : 11:12:47
|
| Mr. MVJ,You are a godsend. Thank you very much.I noticed that the results are printed dd/mm/yyyy. Is there a way to have it printed mm/dd/yyyy? |
 |
|
|
Srinika
Master Smack Fu Yak Hacker
1378 Posts |
Posted - 2006-05-09 : 15:09:18
|
| rohcky, check the Books Online (SQL Server Help) - Convert - Transact SQLU will find how to get the various date formatsAlso u can make use of the Front End side formatting.Srinika |
 |
|
|
|
|
|