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 2000 Forums
 Transact-SQL (2000)
 Date convert

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 varchar

something like this, depending on what your actual data looks like
DECLARE @date datetime
SET @date = current_timestamp
SELECT LEFT(CONVERT(varchar(10),@date,101),2)+ ' - ' + RIGHT(CONVERT(varchar(10),@date,101),4

Jim
Go to Top of Page

kkmurthy
Starting Member

41 Posts

Posted - 2008-03-17 : 12:04:42
Thank you
Go to Top of Page
   

- Advertisement -