Monday, February 02, 2015

SQL Trick KB: Algorithm - First Date of Financial Year

I was trying to implement a stored procedure with some function working based on the first date of the financial year for any given date. In Australia, our financial year start on the 1st of July. So, for example, if today is '2015-06-30', then it should return the '2014-07-01' as the first date of FY15, while if the date '2015-07-02' would return the next financial year FY16 with the start date as '2015-07-01'.

Sounds easy, huh? I was working on some CASE...WHEN statement, until I found this piece of brilliant, clean-cut idea, and thought that this is just so simple. It is from damien-the-unbeliever's answer at the Most efficient way to calculate the first day of the current Financial Year? at stackoverflow.com.

No comments:

Post a Comment