Formatting the Month and Year from a datetime field in SQL Server 2008 -
i need display month , year datetime
field in sql server 2008.
this should formatted in following way:
jan 13 feb 13 march 13
etc
i need group , order these results
i've tried many permutations of cast
, convert
, datepart
etc can't quite need.
any suggestions?
select (left(convert(char(11), date, 107), 3) + " " + right(convert(char(11), date, 107), 2)) date ( select date yourtable group date order year(date) asc, month(date)asc )
convert 107
give format mmm dd, yyyy
, need month , last 2 digits of year we'll use left
function mmm
, right function last 2 digits of year
update: add support sorting , grouping. , can add clause sub query conditioning
Comments
Post a Comment