Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Query Report Builder - Fiscal Year CASE statement

Posted on 2011-03-25
2
Medium Priority
?
1,782 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
2 Comments
 
LVL 3

Accepted Solution

by:
bhoenig earned 1000 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction: This article is aimed at report developers who are used to developing reports using relational databases and have gotten a first-time assignment to develop reports on OLAP cubes. It demonstrates how to build a report using SQL Ser…
A recent questions about how to add SSRS named instances, couldn't find any that talks about SQL server 2008, anyway I decided to help by creating some screen shots. The installation is straightforward, you just pop the SQL server 2008 installati…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Loops Section Overview
Suggested Courses

963 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