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 |
kkmurthy
Starting Member
41 Posts |
Posted - 2008-03-17 : 11:42:17
|
can some one help me in coverting date as followe:I want date in 'MM-YYYY' format as date itself and not as varchar since I have to compare the dates.I know conversions like select convert(varchar(11),getdate(),102)etc |
|
jimf
Master Smack Fu Yak Hacker
2875 Posts |
Posted - 2008-03-17 : 11:53:51
|
MM-YYYY is a varchar, not a date, so you'll have to convert the date in the datetime format to a varcharsomething like this, depending on what your actual data looks likeDECLARE @date datetimeSET @date = current_timestamp SELECT LEFT(CONVERT(varchar(10),@date,101),2)+ ' - ' + RIGHT(CONVERT(varchar(10),@date,101),4Jim |
 |
|
kkmurthy
Starting Member
41 Posts |
Posted - 2008-03-17 : 12:04:42
|
Thank you |
 |
|
|
|
|