# Trying to determine duration between 2 date fields to see if it was completed on time, get type mismatch?

• 0
• Question
• Updated 3 years ago

Trying to determine duration between 2 date fields to see if it was completed on time, Like:  if([Field1]-[Field2] >0, "Overdue","On-Time")  Get the type mismatch error when I save, any tips?

• 0 Points

Posted 3 years ago

• 0

Ⲇanom the ultimate (Dan Diebolt), Champion

• 30,064 Points
All these should work (untested):

If(ToWeeks([Field1]-[Field2]) > 0, "Overdue","On-Time")
If(ToDays([Field1]-[Field2]) > 0, "Overdue","On-Time")
If(ToHours([Field1]-[Field2]) > 0, "Overdue","On-Time")
If(ToMinutes([Field1]-[Field2]) > 0, "Overdue","On-Time")
If(ToSeconds([Field1]-[Field2]) > 0, "Overdue","On-Time")
If(ToMSeconds([Field1]-[Field2]) > 0, "Overdue","On-Time")

[Field1]-[Field2] is a duration not a number to you have to call one of the conversion functions co convert a duration to a number before the test is performed.

QuickBaseCoach App Dev./Training, Champion

• 65,542 Points
You can try this

if([Field1]-[Field2] > Days(0), "Overdue","On-Time")

Since you are subtracting dates, the result will be a Duration.  So you need to compare it to a Duration.

Ⲇanom the ultimate (Dan Diebolt), Champion

• 30,064 Points
You got me there. I updated my answer.

Ⲇanom the ultimate (Dan Diebolt), Champion

• 30,064 Points
Better still:

If( [Field1] > [Field2] , "Overdue" , "On-Time")

QuickBaseCoach App Dev./Training, Champion

• 65,542 Points
Ok, I agree.