Capture Last check-in date & days since

Capture Last check-in date & days since


I have two custom fields on my Account form, these are "Date of Last Check-In" and "Days Since Last Contact"


Using a custom function how can I pull the date from the last check-in and display it in the field "Date of Last Check-In"? and then also display the number of days since last check-in in the "Days SInce Last Contact" field?

I tried following a couple of examples but got myself into a bit of a muddle!