Search code examples
datediffspotfire

Days between one date till today. Not difference (Spotfire)


I'm trying to find how many days between a date and today.

I'm able to get the correct number of days but it show as negative.

Integer(DateDiff("day",Date(DateTimeNow()),Date([LAST_RECORD_DT])))

I would like the same result but positive number.


Solution

  • Your answer in your comment is good, but this is better in my opinion:

    If LAST_RECORD_DT is in the past (which seems to be the case for you):

    Integer(DateDiff("day",Date([LAST_RECORD_DT]),Date(DateTimeNow())))
    

    If LAST_RECORD_DT is in the future:

    Integer(DateDiff("day",Date(DateTimeNow()),Date([LAST_RECORD_DT])))
    

    If you want it to always be positive, you can use Abs:

     Abs(Integer(DateDiff("day",Date([LAST_RECORD_DT]),Date(DateTimeNow()))))