Oracle Analytics Cloud and Server

Welcome to the Oracle Analytics Community: Please complete your User Profile and upload your Profile Picture

Calculate number of days for February in a leap year - MOD Functon in OBIEE 11g

Received Response
31
Views
2
Comments
OBIEE_Drool
OBIEE_Drool Rank 4 - Community Specialist

Hello,

I am trying to calculate number of days in February for different years. How do I deal with a leap year? I found this formula online but I am not sure if MOD function works in OBIEE 11g.

(CASE WHEN Month (“Table Date”.”Date”) IN (1, 3, 5, 7, 8, 10, 12) THEN 31

WHEN Month (“Table Date”.”Date”) IN (4, 6, 9, 11) THEN 30

ELSE (CASE WHEN (MOD (YEAR (“Table Date”.”Date”), 4) = 0 AND MOD (YEAR (“Table Date”.”Date”), 100)! = 0) OR (MOD (YEAR (“Table Date”.”Date”), 400) = 0) THEN 29

ELSE 28 END) END)


Appreciate any inputs or alternate solutions. Thanks in advance.

Answers

  • OBIEE_Drool wrote:
    
     I am not sure if MOD function works in OBIEE 11g.
    

    Yes, MOD is an OBIEE 11g function

    SelectedMod‎
    Syntax

    MOD(expr1, expr2)

    Where

    expr is any expression that evaluates to a numerical value.

    Example
    Description

    Divides the first numerical expression by the second numerical expression and returns the remainder portion of the quotient.

  • OBIEE_Drool
    OBIEE_Drool Rank 4 - Community Specialist

    Sorry it was the spaces that were causing the syntax issue. Thanks @Gianni Ceresa