• Indeed.

    You can eliminate 7 evaluations from the vast majority of leap year candidates by simplifying and reordering the predicates:

    SELECT

    CASE

    WHEN @CurrentMonth in (1, 3, 5, 7, 8, 10, 12) THEN 31

    WHEN @CurrentMonth in (4, 6, 9, 11) THEN 30

    -- only '@CurrentMonth = 2' left

    WHEN @YearNo % 4 > 0 THEN 28 -- not divisible by 4 => not leap year

    -- only years divisible by 4 left; century leap years must be divisible by 400

    WHEN @YearNo % 100 > 0 THEN 29 -- not a century year => leap year

    WHEN @YearNo % 400 = 0 THEN 29 -- is divisible by 400 => leap year

    ELSE 28

    END AS DaysInMonth;

    Admitedly, in this application where we're evaluating DaysInMonth only once, the loss of code clarity doesn't justify the simplification. If you were applying this DaysInMonth function to a large volume of currentMonth values, however, it would be worth considering.