Search
 
SCRIPT & CODE EXAMPLE
 

SQL

sql get actual fiscal year

CREATE FUNCTION dbo.fnc_FiscalYear(
    @AsOf           DATETIME
)
RETURNS INT
AS
BEGIN

    DECLARE @Answer     INT

    -- You define what you want here (September being your changeover month)
    IF ( MONTH(@AsOf) < 9 )
        SET @Answer = YEAR(@AsOf) - 1
    ELSE
        SET @Answer = YEAR(@AsOf)


    RETURN @Answer

END

GO


 -- Use it like this 
 
 SELECT dbo.fnc_FiscalYear('9/1/2009')


SELECT dbo.fnc_FiscalYear('8/31/2009')
Comment

PREVIOUS NEXT
Code Example
Sql :: how to check last index rebuild sql server 
Sql :: get number of rows in every table mysql 
Sql :: time in sql server 
Sql :: alter session set nls_language french 
Sql :: SQL DATEDIFF(date_part, start_date, end_date) 
Sql :: sql delete duplicate rows but keep one 
Sql :: c# sql conennection string 
Sql :: oracle boolean to varchar 
Sql :: insert using condition postgres 
Sql :: Unable to locate package libmysql-java 
Sql :: execution order in sql 
Sql :: select all from table left join 
Sql :: Write an SQL query to fetch the count of employees working in the department ‘Admin’. 
Sql :: mysql pass command from command line 
Sql :: rename temp table column name in sql server 
Sql :: mysql remove tabs from string 
Sql :: insert or update cassandra 
Sql :: sql join on wildcard 
Sql :: foreign key in sql dbms 
Sql :: except in sql 
Sql :: learn sql 
Sql :: creashed table mysql 
Sql :: sql: extract day text from datetime value 
Sql :: ubuntu install mysql 5.7 
Sql :: sql order by clause 
Sql :: sql xor 
Sql :: sql ssrs 
Sql :: ignore duplicate rows in sqlite 
Sql :: sql server concat null 
Sql :: install sql server management studio ubuntu 
ADD CONTENT
Topic
Content
Source link
Name
1+8 =