Tap Forms – Organizer Database App for Mac, iPhone, and iPad › Forums › Using Tap Forms › How does calculation field work?
- This topic has 7 replies, 5 voices, and was last updated 5 years, 7 months ago by Brendan.
-
AuthorPosts
-
January 29, 2013 at 2:59 PM #5893
LateralParticipantHi Brendan
Can you explain how the calculation field type works and provide a sample scenario?
Regards
GregJanuary 29, 2013 at 4:18 PM #5895
BrendanKeymasterHi Greg,
A calculation field can be as simple as a mathematical calculation. E.g. 5 + 10. But that wouldn’t be very useful. It’s best when used in combination with another field. You can use Numbers, Ratings, Check Marks, and any of the Date / Time field types in a formula.
For example, if you wanted to calculate a person’s age based on a separate Birth Date field, you could create a formula like:
($now – [Birth Date]) / 60 / 60 / 24 / 365
The result of a date calculation is always in seconds. So dividing by 60 / 60 / 24 / 365 will give you the result in years.
If you were to do something like multiply that result by a Check Mark field, then the result would be multiplied by 0 or 1 depending on the state of the check mark field value for that record. So it could be useful for some things.
Let me know if you need further information on that or if you have specific examples in mind.
Thanks!
Brendan
January 31, 2013 at 11:19 AM #5899
Frans48ParticipantI was born on 15 september 1948. Suppose there is an event on 31 January 1953, set out in the field ‘EventDate’. I want to know how old I was.
Which formula should I use?
(EventDate – $Birthday) / 60/60/24/365,25
(365.25 because of leap years)
How do I insert the constant $Birthday, wich does not have to be in every record.February 1, 2013 at 10:33 PM #5901
BrendanKeymaster$Birthday is not a supported command. Only $now is.
But you could use ([Event Date] – [Birth Date]), which will give you the number of seconds between those two date fields. Then you just need to convert that into years. So divide it like / 60 / 60 / 24 / 365. I’m not sure about the leap year thing, but it won’t make much of a difference I imagine if you use 365.25.
Brendan
November 27, 2013 at 5:08 AM #7889
gaxtaParticipantHi Brendan
Im new to Tapforms and like the program, Im trying new calculation based on the example of birth dates, but the result is still always 0 in the age field.I have created a field ‘Birth date’ I then created a another field ‘calculation’ and called it ‘age’. within the calculation formula I inserted the example above i.e.:
($now – [Birth Date]) / 60 / 60 / 24 / 365
The result is always 0
What Im I doing wrong?
Graham
November 27, 2013 at 1:50 PM #7893
BrendanKeymasterHi Graham,
Can you please email me your form template? I’ll look into it. But it looks like you’ve done it right.
Thanks,
Brendan
October 3, 2018 at 7:26 PM #30898
Ken KempParticipantI want to keep records of time spent on projects: FINISH-START=TIME
See attached screenshot – is this the right formula for a calculated field?THANKS
KenAttachments:
You must be logged in to view attached files.October 3, 2018 at 8:56 PM #30900
BrendanKeymasterHi Ken,
Yes, that’s right. The result will be the number of seconds between those two times.
So you’ll want to apply a Number Format to convert that to HH:MM or HH:MM:SS or one of the other duration formats.
Thanks!
Brendan
-
AuthorPosts
You must be logged in to reply to this topic.