Calculate the number of days between Today and Date Modified

  • 0
  • 1
  • Question
  • Updated 5 months ago
  • Answered
I need a formula to calculate from todays date to the time a project was last modified.
Any help would be appreciated!!
Photo of Kurt Kelsey

Kurt Kelsey

  • 230 Points 100 badge 2x thumb

Posted 11 months ago

  • 0
  • 1
Photo of QuickBasePros_IDS

QuickBasePros_IDS, Champion

  • 4,516 Points 4k badge 2x thumb
Today() - [Date Modified]
If you want a numeric field for the # of days , it would be
ToDays(Today() - ToDate([Date Modified]))
Photo of Kurt Kelsey

Kurt Kelsey

  • 230 Points 100 badge 2x thumb
Here is what I get:

The expression Today() on the left hand side of the operator "-" is of type datewhile the expression [Date Modified] on the right hand side is of type date/time. The operator "-" cannot be used with these types of expressions.
Photo of QuickBasePros_IDS

QuickBasePros_IDS, Champion

  • 4,516 Points 4k badge 2x thumb
This is because the [Date Modified] is a Date/Time field, and Today() is a "Date" value. 

Mark's comment about displaying the number of days as a numeric value would be the formula to use:

ToDays(Today() - ToDate([Date Modified]))
Did you try my formula as a Formula numeric field type?
Photo of Kurt Kelsey

Kurt Kelsey

  • 230 Points 100 badge 2x thumb
Worked like a charm!!!  Thank you kindly.
Photo of Katrina E

Katrina E

  • 310 Points 250 badge 2x thumb
I'm trying to get the difference between todays date and the expected start date of a project but if the project has been started already, I want the value to be NA.  I have a text field and it's not letting me put the "-", if I do a numeric, it won't let me do the value NA

If(
not IsNull([Started]),"N/A",
ToText(([Start])-(Now())
)
)
Photo of Katrina E

Katrina E

  • 310 Points 250 badge 2x thumb
That worked! Thank you!  One last question, I want the value to be negative to indicate that the task has been done after the expected start date.  I tried to just reverse the 2 functions but now it doesn't work. 
Sure, I made the assumption that you wanted a positive number

If(
not IsNull([Started]),"N/A",
ToText(ToDays(ToDate([Start]) - Today())))
Photo of Katrina E

Katrina E

  • 310 Points 250 badge 2x thumb
Thank you so much!!!!!
Photo of Katrina E

Katrina E

  • 310 Points 250 badge 2x thumb
Ultimate last question on this one.  Is there a way that I can have one decimal place on the number value on this field?
If(
not IsNull([Started]),"N/A",
ToText(ToDays(ToDate([Start]) - Today())))

& ".0"