Question : Syntax error with DATEPART in Calculated field - MS SQL REporting Services

Here is my calculated field that I added to a report. I'm trying to get back a value for our company's fiscal year which runs April 1 to Mar 31.

=IIF(DATEPART(mm, Fields!Date_.Value)<4,DATEPART(yy, Fields!Date_.Value),DATEPART(yy, Fields!Date_.Value)+1)

returns the error: [BC30451] Name 'mm' is not declared.

Also, is there some sort of reference for all the functions, etc.? Is it just pure SQL or are we working with a specific language in SQL Reporting Services?

Thanks

Answer : Syntax error with DATEPART in Calculated field - MS SQL REporting Services

Try:

=IIF(DATEPART(m, Fields!Date_.Value)<4,DATEPART(yy, Fields!Date_.Value),DATEPART(yy, Fields!Date_.Value)+1)

(The interval Month for the DATEPART function is 'm')

Version 2 of Reporting Services has an 'Enhanced Expression Editor' (bit like the one used in Microsoft Access) which will show all of the available expressions that you can use.  It will also allow the use of 'Inline Parameter Information', 'Statement Completion', and 'Real Time Syntax Checking'.

Till the release of version 2, I use the following link to see the available functions, and their parameters:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vblr7/html/vaoriVBRuntimeLibraryKeywords.asp

Hope this helps

Random Solutions  
 
programming4us programming4us