How to calculate the number of days elapsed

madpad

Member
I have two fields, that are both dates -
paydate and today (date_time)
There is also a fixed date, which is due date, say in this case 1 Jun 2014.

I have a calc field, penalty, which should calculate the penalty as follows -
a. If customer has still not paid, then paydate is blank.
In that case, I would like to calculate in days the difference between today and duedate, and calculate penalty based on that (different field)

b. if customer has paid, and paydate is after duedate, then I would like to calculate difference between paydate and duedate in days.

Can someone help with the phpcode that I would need for the calc element?
Thanks for any help.
 
Hello, If you use a PHP, maybe here helps you.
PHP -> http://fabrikar.com/forums/index.php?wiki/common-php-tasks/#dates
Following is copy at there. however this is not included holiday, so you have to write your own programming code about holiday If you need it.
Replace element name to yours, and Past it to different filed where is 'calculation' called . It is Maybe works(I don't have been done it).

PHP:
$a_date = strtotime("{table___element}");
$duedate = strtotime("{table___element}");
$datediff = ($duedate - $a_date);
$diff = round($datediff / 86400);
return $diff;
 
We are in need of some funding.
More details.

Thank you.

Staff online

Members online

Back
Top