AnsweredAssumed Answered

How to calculate date difference using Current_Date

Question asked by tomrip on Nov 3, 2016
Latest reply on Nov 4, 2016 by tomrip

Hello.

I am working with an AGOL hosted feature layer.  I am trying to calc the difference between when a record was added and the current date.

I am using the 'calculate' function that is available by clicking in the 'gear' icon that appears in the upper right corner of a column header.  

The expression i am using is  'AgeInDays = CURRENT_DATE() - DateReceived'. That expression successfully validates.

 

When i click the 'Calculate' button, i get the following error message:

Calculate for the expression 'CURRENT_DATE() - DateReceived' failed.
Implicit conversion from data type datetime to float is not allowed. Use the CONVERT function to run this query.

I have tried various forms of the CONVERT function as suggested by the error message, but i haven't stumbled upon the correct syntax.

 

Any idea why that expression is not working. My reading of the 'working with fields' documentation suggests that the number of days should be returned. In fact when i use two date fields from the table in the expression (rather than CURRENT_DATE), the number of days is returned.  

 

Is there something special i need to do to use 'CURRENT_DATE'?

 

Any suggestions on how to use CURRENT_DATE to get the difference between two dates?

 

Thank you.

Outcomes