# I am trying to calculate "Days since last rainfall" in my form.

850
5
03-14-2018 10:44 AM
New Contributor II

I have inspection date set to today() and a field for date of last rainfall but it is giving nme decimals as answers as it is accounting for hours..how can I change this?  I tried using the round function in the constraints field but it doesn't work.  I also have the field set to integer but it doesn't seem to matter..

5 Replies
Esri Esteemed Contributor

Hi Amy,

Can you share the calculation in the form?  Is it based on epoch time (milliseconds, requiring division at the end) or decimal days (see the 'Constraints and Calculations' section in https://community.esri.com/groups/survey123/blog/2016/04/17/dates-and-time-in-survey123-for-arcgis )?

New Contributor II

Hi James, I got a fix by using the ESRI field types Integer and setting the length to 2, however it still gives me a response of 1., 2., 10, 11 (showing decimal point for any single numbers) so it works but ideally I would just have the whole number with no decimal point. Here is my form, I am trying to calculate row 18 “Date of last rainfall” .

I appreciate any input you may have!!

Amy Storey, LEED®AP | GIS Analyst | NV5<http://www.nv5.com/>

15092 Avenue of Science, Suite 200 | San Diego, CA 92128 | P: 858.385.2175 | C: 619.261.4243 | F: 858.385.0400

Electronic Communications Disclaimer<http://www.nv5.com/contact-us/electronic-communications-disclaimer/>

New Contributor III

I think this will work better if you convert your dates to decimal time. I recently wrote a function to determine when a nest would be 55 days old based on the date it was documented. It looked like this.

date (decimal-date-time(\${Date_Found}) + 55)

I would think you could try something similar. Maybe:

date(decimal-date(\${today} - decimal-date(\${Date_of_Last_Rainfall}))

Let me know if it works.

New Contributor III

Sorry. I had a minute to test my suggestion and I realized there are some mistakes. I was able to make it work though.

round((decimal-date-time(\${Inspection_Date}) - decimal-date-time(\${Last_Rain})),0)

Put this in the calculation column of an integer field and it should work. Be sure to replace the field names with whatever you named your fields in your form.

New Contributor II

That worked perfectly Thanks!!

Amy Storey, LEED®AP | GIS Analyst | NV5<http://www.nv5.com/>

15092 Avenue of Science, Suite 200 | San Diego, CA 92128 | P: 858.385.2175 | C: 619.261.4243 | F: 858.385.0400

Electronic Communications Disclaimer<http://www.nv5.com/contact-us/electronic-communications-disclaimer/>