Simple variable question

  • 0
  • 1
  • Question
  • Updated 4 years ago
  • Answered

I need to add a line to this formula:

var Number DaysToNextDueDate = ToDays ( [Next Due Date] - Today() );


If (


$DaysToNextDueDate > 0 and $DaysToNextDueDate <= 60, "<font color='orange'><b>" & "60" & "</b></font>",


$DaysToNextDueDate > 60 and $DaysToNextDueDate <= 90, "<font color='#99CC00'><b>" & "90" & "</b></font>",


$DaysToNextDueDate > 90, "Good",


""


)


The line I want needs to show if $DaysToNextDueDate < 0 to display the result of the equation in the variable (actual negative number of days) in bold & red.

Basically I don't know how to get the result of the equation in the variable to display.

Photo of Tony

Tony

  • 0 Points

Posted 4 years ago

  • 0
  • 1
Photo of Xavier Fan

Xavier Fan, Champion

  • 340 Points 250 badge 2x thumb
Try this:

var Number DaysToNextDueDate = ToDays ( [Next Due Date] - Today() );

If (

$DaysToNextDueDate <= 0, "<font color='red'><b>" & ToText($DaysToNextDueDate)  & "</b></font>",

$DaysToNextDueDate > 0 and $DaysToNextDueDate <= 60, "<font color='orange'><b>" & "60" & "</b></font>",

$DaysToNextDueDate > 60 and $DaysToNextDueDate <= 90, "<font color='#99CC00'><b>" & "90" & "</b></font>",

$DaysToNextDueDate > 90, "Good",

""

)



$DaysToNextDueDate is the value of the variable, and is a Number.  To convert it to text, we use the "ToText" function:


ToText($DaysToNextDueDate)
Photo of Tony

Tony

  • 0 Points
Once again, that worked perfect! And also once again, thank you so much!
Photo of Xavier Fan

Xavier Fan, Champion

  • 340 Points 250 badge 2x thumb
You're welcome!