Search code examples
spotfire

Integer function with Datediff in Spotfire


I am trying to add a new column in Spotfire so I can get the age of the person in years. This is the function used:

Integer(DateDiff(Date(2018,3,31),Date([Y_BIRTH_DATE],[M_BIRTH_DATE], [D_BIRTH_DATE])))/365

However, the computed column returns as (Empty). If I run the expression without the Integer() and the /365 the function returns the appropriate number of days.


Solution

  • Use the function Days :

    Days(DateDiff(Date(2018,3,31),Date([Y_BIRTH_DATE],[M_BIRTH_DATE], [D_BIRTH_DATE])))/365
    

    Explanation : your result is a timespan, so it cannot be converted to integer. The Days function will extract the integer value of the timespan.