Solved

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

Posted on 2014-12-09
4
147 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 73

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

If you find yourself in this situation “I have used SELECT DISTINCT but I’m getting duplicates” then I'm sorry to say you are using the wrong SQL technique as it only does one thing which is: produces whole rows that are unique. If the results you a…
Composite queries are used to retrieve the results from joining multiple queries after applying any filters. UNION, INTERSECT, MINUS, and UNION ALL are some of the operators used to get certain desired results.​
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

867 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now