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
 General SQL Server Forums
 New to SQL Server Programming
 dateformat

Author  Topic 

gangadhara.ms
Aged Yak Warrior

549 Posts

Posted - 2009-08-27 : 03:04:53
select compdate from tbljoiningdate

Here compdate is a timestamp

here i need to select only month & year from the compdate field how to select ?

senthil_nagore
Master Smack Fu Yak Hacker

1007 Posts

Posted - 2009-08-27 : 03:10:24
Try it

select cast(month(compdate) as varchar(2))+'-'+cast(year(compdate) as varchar(4))

Senthil.C
------------------------------------------------------
[Microsoft][ODBC SQL Server Driver]Operation canceled

http://senthilnagore.blogspot.com/
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-08-27 : 03:43:46
quote:
Originally posted by gangadhara.ms

select compdate from tbljoiningdate

Here compdate is a timestamp

here i need to select only month & year from the compdate field how to select ?



Where do you want to show the formatted dates?

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -