开发者

How to get both month and year together from a date in sql server 2005?

I have a column in report that should display month and year together i.e single column will have both month and year(this is the first column of the table).

Ex: JAN/11

  FEB/11

    .

开发者_如何学Go    .

 DEC/11

How can I do this?

Regards,

N.SRIRAM


I assume datecolumn will be your column name and here goes the query -

select DATENAME(month, datecolumn) + '/' + Right(Year(datecolumn),2) from myTable

if you want to show only first three chars always, then -

select CAST(DATENAME(month,datecolumn) as nvarchar(3)) + '/' + Right(Year(datecolumn),2)
from mytable
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜