# Unable to take the difference between two dates

Hello all,

I am attempting to take the difference of two dates (in number of days). Thus far I am unable to get anything to show other than 0. Please see my UI field setup below.

I have even tried just pulling in one of the dates with the return type of date with nothing showing up. Does anyone know what I am doing wrong?

I have been trying to do something similar to:

https://community.skuid.com/skuid/topics/calculate-age-with-ui-only-field

but again, with no luck.

Thanks,

M$

I am attempting to take the difference of two dates (in number of days). Thus far I am unable to get anything to show other than 0. Please see my UI field setup below.

I have even tried just pulling in one of the dates with the return type of date with nothing showing up. Does anyone know what I am doing wrong?

I have been trying to do something similar to:

https://community.skuid.com/skuid/topics/calculate-age-with-ui-only-field

but again, with no luck.

Thanks,

M$

Tagged:

1

## Comments

The return is milliseconds so if you divide by 86400000 (the number of milliseconds in a day) it will give you the number of days. e.g.

({{field_1__c}} - {{field_2__c}})/86400000

Cheers

Damien

Michael, what kind of date values are you comparing? The Floor() function will give you a 0 for anything less than 1 full day difference. I would recommend increasing the decimal places to 1 or 2, removing the Floor() function, and dividing by 1000*60*60 to look at minutes until you see what the formula is giving you.

Alternatively, try it without floor as it shouldn't matter if they are normal date fields

Try doing the Floor on just the numerator.

FLOOR( {{Service_Start_Date__c}} - {{Implementation_Manager__r.CS_Start_Date__c}}) / (1000*24*60*60)

Thanks,

Bill

Thanks for the great replies. Following Raymond's advice I have eliminated everything and tried testing the output of a single variable and found that I cannot get any field to display. I have tried numbers and dates with matching return type and still nothing is showing up in the table.

Note that I am attempting to create this UI field within an Aggregate Model (for what it's worth). Each row is an opportunity with a service start date in which I would like to have another field counting days from that date and another (for each opp record). Then on a chart I am plotting the cumulative number of opps by owner.

Is there some sort of trick for getting UI fields to pull in merge fields on an Agg model?

Thanks all.