Solved

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

Posted on 2014-12-18
4
149 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
  • 2
4 Comments
 
LVL 51

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 51

Accepted Solution

by:
HainKurt earned 500 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 65

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Via a live example, show how to shrink a transaction log file down to a reasonable size.
Viewers will learn how the fundamental information of how to create a table.

803 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