Jump to content
  • 0

Table Formula Field to Calculate Fiscal Year


Brayton

Question

Our fiscal year begins on July 1 and ends on June 30.  We had created a filter to select, but also people wanted to select and compare fiscal years in their datapages.  So, we wanted to create a Fiscal_Year field that we could refer to, for example if a 'Finish_Date" field was between July 1, 2019 and June 30, 2020 inclusive, set the Fiscal_Year to "1920", as it is integer.   We had some typing issues, but Caspio helped us with the following for Fiscal year 1920 and 2021.  If you have any other suggestions, please let me know.

CASE

/* Fiscal Year 19/20 below */

WHEN CONVERT(DATETIME, [@field:Finish_Date], 101) BETWEEN CONVERT(DATETIME, '07/01/2019', 101) AND CONVERT(DATETIME, '06/30/2020', 101)

THEN

CONVERT(VARCHAR(10), (1920), 101)

/* Fiscal Year 20/21 below */

WHEN CONVERT(DATETIME, [@field:Finish_Date], 101) BETWEEN CONVERT(DATETIME, '07/01/2020', 101) AND CONVERT(DATETIME, '06/30/2021', 101)

THEN

CONVERT(VARCHAR(10), (2021), 101)

ELSE

''

END

Link to comment
Share on other sites

1 answer to this question

Recommended Posts

  • 0

If I got it correct, as long as the date is not after June 30, set the fiiscal year as last year. 

Is that the case?

If yes, perhaps we can use a formula like this:

case 
when Datepart(month,[@field:date]) < 7 then  Datepart(year,[@field:Birth_date]) - 1 
when Datepart(month,[@field:date]) >= 7 then  Datepart(year,[@field:Birth_date]) 
end 

I just used the year as a return value as I am not sure what is the exact value you want but I hope this idea helps

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...