Basic runtime error 380

Hmm a very complex VB script seems to work fine but then I added this simple function.
Works in Excell but not in LibreOffice.

Function YDAYS(D As Date) As Integer
    Dim y, m As Integer
    y = Year(D)
    YDAYS = 365
    If y Mod 400 = 0 Then
        YDAYS = 366
    ElseIf y Mod 100 = 0 Then
    ElseIf y Mod 4 = 0 Then
        YDAYS = 366
    End If
End Function

Hi Anon,

Adding the macro and running the function in Calc (LO 4.0.0.3 + Ubuntu 12.04.2) doesn’t give me an error:

=YDAYS("3/3/2000")

How are you using this function?

@qubit1 Dear friend, never use this format for the date - it will be error. Really, (3/3/2000)=0,0005=“30.12.1899 00:00:43”. It must be DATE(2000;3;3) or DATEVALUE(“3/3/2000”)

@JohnSUN – Ah, okay. Thanks for the pointer. When I looked for date formats I found these docs and when I typed “3/3/2000” into a cell in Calc (no quotes), it seemed to interpret it as a date, so I didn’t know that I needed the quotes to escape the value for the function.

It makes sense, now that you mention it… :slight_smile:

You may want to use the function DAYSINYEAR()?