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
Solved

Query - Fiscal Year July 1 - June 30 from Claim Date

Posted on 2014-12-09
4
152 Views
Last Modified: 2014-12-09
I have a ClaimDate and I want to identify the FY.  The FY in my company if from July 1st through June 30.

I want the just the FY (i.e. 2014) to display as a result.

Thank you!
Scott
0
Comment
Question by:Scott Williams
  • 2
4 Comments
 
LVL 48

Expert Comment

by:PortletPaul
ID: 40489969
What is the database type? (date functions differ between database vendors)
0
 
LVL 74

Accepted Solution

by:
sdstuber earned 400 total points
ID: 40489972
datepart(year,ClaimDate) + case when datepart(month,ClaimDate) < 7 then -1 else 0 end
0
 

Author Comment

by:Scott Williams
ID: 40489973
SQL Server 2012
0
 
LVL 48

Assisted Solution

by:PortletPaul
PortletPaul earned 100 total points
ID: 40489975
try this perhaps:

case when month(ClaimDate) >= 7 then year(ClaimDate) else year(ClaimDate) - 1 end
0

Featured Post

The New “Normal” in Modern Enterprise Operations

DevOps for the modern enterprise offers many benefits — increased agility, productivity, and more, but digital transformation isn’t easy, especially if you’re not addressing the right issues. Register for the webinar to dive into the “new normal” for enterprise modern ops.

Question has a verified solution.

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

'Between' is such a common word we rarely think about it but in SQL it has a very specific definition we should be aware of. While most database vendors will have their own unique phrases to describe it (see references at end) the concept in common …
PL/SQL can be a very powerful tool for working directly with database tables. Being able to loop will allow you to perform more complex operations, but can be a little tricky to write correctly. This article will provide examples of basic loops alon…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

856 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