0

age(some_date) function not working on Console

age(anydate) works when used on a formula field.

But does not work on the console!!!

I'm getting the following message:

Function is not defined: age([date]) at line 2, column 0

Is that a bug or am I missing something?

5 replies

null
    • Sean
    • 4 yrs ago
    • Reported - view

    Don't use the square brackets even if the date is from an array. You'll need to use the item() function if the date is in an array.

    • JGM
    • Jose_Monteiro
    • 4 yrs ago
    • Reported - view

    I'm using the following code:

    (select Table1 where Id = 1).Data    
    /* BTW Data is the portuguese for Date */

    which returns a date (and the following is a date data type):
    4 Jun 2017

    Then using the age function:
    age((select Table1 where Id = 1).Data)

    I get an error message:
    Function is not defined: age([date]) at line 2, column 38

    I'm not using square brackets; they are part of the error message.

    • Sean
    • 4 yrs ago
    • Reported - view

    The square brackets are an indication of what it is getting and what the error is. My understanding is the select statement returns an array even if it is empty. You suggested it worked in a Formula field, but not the Console. I did not find that to be true. This works...

     

    age(item((select Table1 where Id = 1).Data, 0))

     

    But, if you know the record Id it would be simpler to do this...

     

    age(record(Table1, Id).Data)

    • JGM
    • Jose_Monteiro
    • 4 yrs ago
    • Reported - view

    Thanks for you help.

    You must be absolutely right.
    Your 2 statements worked fine.

    So we must conclude that:
    1. Any select statment always returns an array, having it any number of elements, just one or none.
    2. Square brackets in the error message means exactly that: an array is being returned.
    3. And even if the array has only one element, to get an element from the array we must use the item() function.

    • Support
    • 4 yrs ago
    • Reported - view

    Spot on :-)

    Birger

Content aside

  • 4 yrs agoLast active
  • 5Replies
  • 1355Views