?
Solved

SQL Fiscal Year Starting 7/1 - Ending 6/30

Posted on 2014-12-18
4
Medium Priority
?
156 Views
Last Modified: 2015-09-22
Could you please help me create formulas for these -in SQL 2012:

FY Starting 7/1 - Ending 6/30

1) FY End Date of GETDATE()
2) FY End Date of Last year
3) FY Start Date - 10 years ago

Each of these should be in format m/d/yyyy - 7/1/2014

Thanks so much!
Scott
0
Comment
Question by:Scott Williams
[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
4 Comments
 
LVL 57

Expert Comment

by:HainKurt
ID: 40507566
here

\
select 
CAST(cast(datepart(year,getdate()) as varchar)+'0630'  AS date) fye_this,
CAST(cast(datepart(year,getdate())-1 as varchar)+'0630'  AS date) fye_last,
CAST(cast(datepart(year,getdate())-10 as varchar)+'0701'  AS date) fys_past10year

fye_this	fye_last	fys_past10year
2014-06-30	2013-06-30	2004-07-01

Open in new window

0
 
LVL 57

Accepted Solution

by:
HainKurt earned 2000 total points
ID: 40507570
and you can use convert(varchar,getdate(),101) to convert to mm/dd/yyyy

select 
convert(varchar,CAST(cast(datepart(year,getdate()) as varchar)+'0630'  AS date),101) fye_this,
convert(varchar,CAST(cast(datepart(year,getdate())-1 as varchar)+'0630'  AS date),101) fye_last,
convert(varchar,CAST(cast(datepart(year,getdate())-10 as varchar)+'0701'  AS date),101) fys_past10year

fye_this	fye_last	fys_past10year
06/30/2014	06/30/2013	07/01/2004

Open in new window

0
 

Author Closing Comment

by:Scott Williams
ID: 40507644
Thanks a lot!!!
0
 
LVL 66

Expert Comment

by:Jim Horn
ID: 40988979
Scott - I just kicked out an article that deals specifically with Fiscal calendar planning --> SQL Server Calendar Table:  Fiscal Years.   Let me know if this helps you, and if yes please click on the 'Good Article' button and provide some feedback.  Thanks.
0

Featured Post

Does Your Cloud Backup Use Blockchain Technology?

Blockchain technology has already revolutionized finance thanks to Bitcoin. Now it's disrupting other areas, including the realm of data protection. Learn how blockchain is now being used to authenticate backup files and keep them safe from hackers.

Question has a verified solution.

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

I have a large data set and a SSIS package. How can I load this file in multi threading?
Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Suggested Courses

800 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