Code Library

DAX · UDF

Date.FiscalYear

Ano fiscal da data, identificado pelo ano em que termina.

Categoria: Ano fiscalTipo: UDFVersão: v1.1.0Fonte: Paulo André Jesus — OfficeTuningAtualizado em: 25/09/2026
Documentação completa na Function Library →

Sintaxe

Date.FiscalYear ( pDate, pStartMonth )

Argumentos

NomeTipoObrigatórioDescrição
pDateDATETIME VALSimData.
pStartMonthINT64 VALSimMês de início do ano fiscal (1 a 12).

Retorno

Número inteiro

Código completo

DEFINE
    /// Ano fiscal da data, identificado pelo ano em que termina.
    /// @param {DATETIME} pDate - Data.
    /// @param {INT64} pStartMonth - Mês de início do ano fiscal (1 a 12).
    /// @returns Ano fiscal. Com início em janeiro, é o próprio ano civil.
    FUNCTION Date.FiscalYear =
        ( pDate : DATETIME VAL, pStartMonth : INT64 VAL ) =>
        YEAR ( pDate ) + IF ( pStartMonth > 1 && MONTH ( pDate ) >= pStartMonth, 1, 0 )

EVALUATE
{ Date.FiscalYear ( DATE ( 2025, 8, 1 ), 7 ), Date.FiscalYear ( DATE ( 2025, 8, 1 ), 1 ) }  // 2026 · 2025

Exemplos

EVALUATE { Date.FiscalYear ( DATE ( 2025, 8, 1 ), 7 ), Date.FiscalYear ( DATE ( 2025, 8, 1 ), 1 ) }
// 2026 · 2025

Dicas e observações

💡 Com início em janeiro, devolve o próprio ano civil. 💡 Mesma convenção de DataHora.Calendario.