Solved

Query Report Builder - Fiscal Year CASE statement

Posted on 2011-03-25
2
1,711 Views
Last Modified: 2012-05-11
Please assist with this query. I am trying to create two additional fields in my dataset. One is for State Fiscal Year (State_FY) and one for Federal Fiscal Year (Fed_FY).  I'm not getting the results I expected.  How can I modify the query to assign the correct state fy and fed fy?
State FY runs 9/1 to 8/31 and Fed FY runs 10/1 - 9/30
 Screen Shot existing Syntax and results
0
Comment
Question by:gberkeley
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 3

Accepted Solution

by:
bhoenig earned 250 total points
ID: 35221046
In your case statements, you are using the MONTH and YEAR functions.  Those functions expect a date parameter and you are passing in a integer.  Since the SERVICE_MONTH column already is an integer, you don't need to get the MONTH of it.  Currently you are doing this MONTH(11) and 11 as a date is actually "1900-01-12 00:00:00.000".  My example code will show this better.

/* Run this to show why you aren't getting the results that you want. */
select month(11)
select year(2005)

/* You need to use the date column */
select month('11/1/2005 12:00:00 AM')
select year('11/1/2005 12:00:00 AM')

/* The real date value of 11 and 2005.  The number of days from 1/1/1900 */
select cast(11 as datetime)
select cast(2005 as datetime)

Open in new window

0
 

Author Closing Comment

by:gberkeley
ID: 35223986
Thanks for the assist!!!
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Written by Valentino Vranken. Introduction: In a previous article (http://www.experts-exchange.com/articles/Microsoft/Development/MS-SQL-Server/MS-SQL_Reporting/Reporting-On-Data-From-Stored-Procedures-part-1.html) I announced that I would writ…
It is helpful to note: This is a cosmetic update and is not required, but should help your reports look better for your boss.  This issue has manifested itself in SSRS version 3.0 is where I have seen this behavior in.  And this behavior is only see…
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question