# Simple variable question

• 0
• 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.

• 0 Points

Posted 4 years ago

• 0

Xavier Fan, Champion

• 570 Points
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)
• 0 Points
Once again, that worked perfect! And also once again, thank you so much!

Xavier Fan, Champion

• 570 Points
You're welcome!