TSQL – Calculate Is Current Fiscal Year and Is Previous Fiscal Year

The following sample shows how to calculate IsCurrent and IsPrevious Fiscal or Financial year indicators from your full date column in your date dimension.

CASE

WHEN MONTH(full_date) < 7 and YEAR(full_date) = YEAR(getdate()) THEN 'Yes'
 WHEN MONTH(full_date) > 6 and YEAR(full_date) = YEAR(getdate())-1 THEN 'Yes'
 ELSE 'No' END AS IsCurrentFinancialYear,

CASE
 WHEN MONTH(full_date) < 7 and YEAR(full_date) = YEAR(getdate())-1 THEN 'Yes'
 WHEN MONTH(full_date) > 6 and YEAR(full_date) = YEAR(getdate())-2 THEN 'Yes'
 ELSE 'No' END AS IsPreviousFinancialYear

About AussieBICG

Connect with me here https://au.linkedin.com/in/aussiebicg

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s