Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Converting calendar date into fiscal year


Converting calendar date into fiscal year

Author
Message
andoxcv 12409
andoxcv 12409
Forum Newbie
Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)

Group: General Forum Members
Points: 4 Visits: 9
Hi

I am in R3 SSRS and adding a new field by converting calendar date into Fiscal Year, i.e. 2014-15.

I used a formula but I was getting an error message, such "The arguments to the following functions are not valid: CONCAT"

Below is my formula:
IF(MONTH(Incident Date)<4,YEAR(Incident Date)-1&"-"&RIGHT(YEAR(Incident Date),2),YEAR(Incident Date)&"-"&RIGHT(YEAR(Incident Date)+1,2))

What could be the issue here? Greatly appreciate your assistance, thanks!

Andy
free_mascot
free_mascot
SSCrazy
SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)

Group: General Forum Members
Points: 2881 Visits: 2235
Here is the small code which will help you:

DECLARE @d SMALLINT
SELECT @d = (SELECT Datepart("yy", Getdate()))
SELECT Concat(@d, '-', RIGHT(@d + 1, 2))

---------------------------------------------------
"Thare are only 10 types of people in the world:
Those who understand binary, and those who don't."
pietlinden
pietlinden
SSCrazy
SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)

Group: General Forum Members
Points: 2185 Visits: 12543
converting calendar date into Fiscal Year


The most flexible way of doing this is to create a Calendar table in your database and populate it. Then you can join in your query to the Calendar table and use any of the columns there that you need.

Here's an article that discusses it and explains how it works.

http://www.sqlservercentral.com/articles/T-SQL/70482/
Lynn Pettis
Lynn Pettis
SSC-Insane
SSC-Insane (24K reputation)SSC-Insane (24K reputation)SSC-Insane (24K reputation)SSC-Insane (24K reputation)SSC-Insane (24K reputation)SSC-Insane (24K reputation)SSC-Insane (24K reputation)SSC-Insane (24K reputation)

Group: General Forum Members
Points: 24233 Visits: 37978
Here is a SQL way to do this easily:



declare @Date date = '20140201';
select cast(YEAR(dateadd(month,9,@Date))-1 as varchar(4)) + '-' + cast(YEAR(dateadd(month,9,@Date)) as varchar(4))

set @Date = '20140612';
select cast(YEAR(dateadd(month,9,@Date))-1 as varchar(4)) + '-' + cast(YEAR(dateadd(month,9,@Date)) as varchar(4))




Cool
Lynn Pettis

For better assistance in answering your questions, click here
For tips to get better help with Performance Problems, click here
For Running Totals and its variations, click here or when working with partitioned tables
For more about Tally Tables, click here
For more about Cross Tabs and Pivots, click here and here
Managing Transaction Logs

SQL Musings from the Desert Fountain Valley SQL (My Mirror Blog)
andoxcv 12409
andoxcv 12409
Forum Newbie
Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)

Group: General Forum Members
Points: 4 Visits: 9
Hi

Thanks for the reply but what I did is to create a new table that will concatenate the two period eventually, and it works:-)

Cheers
Ands
andoxcv 12409
andoxcv 12409
Forum Newbie
Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)

Group: General Forum Members
Points: 4 Visits: 9
Hi

Thanks for the reply but what I did is to create a new table that will concatenate the two period eventually, and it works!!!;-)
andoxcv 12409
andoxcv 12409
Forum Newbie
Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)

Group: General Forum Members
Points: 4 Visits: 9
Great thanks matey! this one works for me...:-D
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search