Breaking up parameters

One of my parameters is a particular date (in the datetime format 11/05/2002 12:00:00 AM) and I wanted to display only the month and year. How can I do this to just display November 2002 on my report.

Answer this question

Breaking up parameters

  • GMohr

    Im using visual basic business intelligence. I did figure out the year...

    =Year(Parameters!reportdate.Value)

    I want the month to be displayed as November, January, July...etc not 11, 1, 7 '

    =Month(Parameters!reportdate.Value) gives me 10 which I dont want

    and

    =MonthName(Parameters!reportdate.Value) gives me an error. I am using SQL 2000.


  • leamas

    try the following

    Switch(Month(Parameters!BeginDate.Value)=01,"January" & Year(Parameters!BeginDate.Value),Month(Parameters!BeginDate.Value)=02,"Feb" & Year( Parameters!BeginDate.Value) )



  • Genyus

    Try the code that I gave above. My output from running the statement

    select DATENAME(m, @CurrentDate) + ' ' + DATENAME(yy, @CurrentDate)

    is:

    Column1
    -------------------------------------------------------------
    April 2006
    No rows affected.
    (1 row(s) returned)

    That gives the month name (not number), as you requested...


  • TBJ

    The DATENAME function should also work in SQL Server 2000 - have a look here:
    http://msdn.microsoft.com/library/default.asp url=/library/en-us/tsqlref/ts_da-db_1dph.asp

    Also have a look at this article for some further examples:
    http://www.sqljunkies.com/Article/6676BEAE-1967-402D-9578-9A1C7FD826E5.scuk



  • Ray_GTI-R

    Have a look at:
    http://msdn2.microsoft.com/en-US/library/ms174395(SQL.90).aspx

    It's the documentation for the TSQL DATENAME command.


  • Polican

    Try using the DATENAME function. Here's an example using the current date:

    declare @CurrentDate datetime
    set @CurrentDate = GetDate()

    select DATENAME(m, @CurrentDate) + ' ' + DATENAME(yy, @CurrentDate)



  • Breaking up parameters