Monday, April 27, 2009

When I am working with reports, this is what every time I am looking for. Everyone gives date on the report as input, and I want display the month name on the report instead of month index [1-12]. So, how to do it?

please use the below script to get the name of the month by month index.
DateName(month, convert( datetime, '2007-' + cast(month(getdate()) as varchar(2)) + '-01', 120))

Here month(getdate()) returns the current month index from getdate() function. Hope this helps...
Categories: ,

4 comments:

  1. Thanks.
    This is what I am exctly looking for

    ReplyDelete
  2. Thanks for the nice post.

    ReplyDelete
  3. Thanks a ton....
    It was very helpful....

    ReplyDelete
  4. What's wrong with

    DateName(month, getdate())

    ReplyDelete