Forum Discussion

ArchiveUser's avatar
ArchiveUser
Qrew Captain
7 years ago

Countdown days until a specified date

So I have two fields: the first is a projected 'delivery date' and the second is a 'how many days until delivery" (essentially, its a countdown).  On the Days-Until-Delivery field I have the following formula:

ToDays([Projected Launch Date] - Today())

And it works great. Problem is, after it reaches the due-date, it starts to show a negative value.  I would like it to simply 'zero' out once the due-date is achieved (I already have it set-up to show any records that are past the due-date to be highlighted in red). Any suggestions on how to code this out?

Thanks in advance for your help.
  • if you want a zero, this this will work

    Max(ToDays([Projected Launch Date] - Today()),0)

    That way it will never go below zero.

    But if you want null (blank) then it would be

    var number Countdown = ToDays([Projected Launch Date] - Today());

    IF($Countdown >0, $Countdown)
    • ReneJamis1's avatar
      ReneJamis1
      Qrew Member

      Greetings,

      This post is the one I found would be most relevant.

      I  have a report containing fields [QName], [Overall End], and {Next Val Date] which is a report formula (Formula - Date) containing ToDate([Overall End]) + Days(90).  This performs exactly as needed..

      I tried adding a filter that would only show the records that were within 5 days of [Next Val Date] however, the criteria is a text field rather than allowing me to select a date 5 days before [Next Val Date].

      I found this post and tried both suggestions but I don't have [Next Val date] to select from in the fields drop-down.

      I used {Formula - Date/Date/Time/Numeric/Duration] but none showed [next Val Date] in the fields list.

      What am I missing here??



      ------------------------------
      Rene Jamis
      ------------------------------
      • ChayceDuncan's avatar
        ChayceDuncan
        Qrew Captain

        Are you just trying to filter the report specifically when next value date within the next 5 days? The simplest solution to get around the quirkiness of using report-formulas as filters is to define a true/false value in the report formula itself. So instead of making a date field as the report formula, make it a formula checkbox. 

        In that checkbox - do something like: 

        field name: Filter

        ((ToDate([Overall End]) + Days(90) - Today()) <= Days(5)

        That will give you a true false response. In your actual filters then - you can pick this report formula and your actual comparator will be equal to 1

        In this case - since the report has a hard time identifying the schema of the report formula on fly - you're comparing the value of a checkbox to "1" / binary value of True.



        ------------------------------
        Chayce Duncan
        ------------------------------
    • ArchiveUser's avatar
      ArchiveUser
      Qrew Captain
      Thanks - I'm really glad that I asked, since my solutions were not even close to what you have there (and also why they weren't working!).  I do like the idea of the null, so I appreciate that suggestion, as well.