I created a Conference Request form (Confi Forms) and am using a Simple Date field type to capture the startdate and enddate (field names). I would like the next field (totaldays) to auto populate the total days.
startdate to enddate = totaldays (how many days our employee will be gone to the conference)
I set totaldays to a Calculated field type and am hoping there's a simple expression that I can add to do the math.
If your users might edit the entry after it is created then you would want to use a formula type instead. Calculated fields are only evaluated on creation of the entry. Formula fields are evaluated on every save. Anyway, the expression to use is below.
(([entry.enddate]-[entry.startdate])/86400000) + 1
FYI, the reason for this is that the dates are stored on the backend as milliseconds since January 1, 1970. So, you can subtract the two numbers and divide by 86400000 (the number of milliseconds in a day) to get the number of days between start day 00:00 and end day 00:00. The +1 at the end is because the date is stored as the beginning of each day and you probably want them out all of the the end day ... hence the need to add 1.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you! Front-end web and multimedia designer – very new to anything outside of HTML, CSS and light JavaScript. Help is so, so appreciated.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Davin. Would you be able to help me with a similar formula?
I'm attempting to subtract two time entries using the confiforms "calculated" field option. Working off of what you did I tried using this> "(([entry.Timeclientrequested]-[entry.firstattempt]) /3600000)" thinking I could use milliseconds in an hour and accomplish the same thing. No dice though, the format is AM PM for time, maybe thats throwing it off.
This would be a great help.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I'll answer it over on your other question.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.