This topic is locked

How to calculate dates on the fly and use that calculated value

12/27/2010 4:29:43 AM
PHPRunner General questions
S
Shinzon author

I saw this (http://xlinesoft.com/phprunner/docs/how_to_calculate_values_on_the_fly.htm) but i want to calculate dates.

I want to calculate days based on start date and end date.

For example:



Start date: 2010-12-25

End date: 2010-12-30

Days: 5


How to get that number 5? And how to use that value? For example i want to print that value on two places on page or i want to use that value in some SQL query.

Thanks.

J
Jane 12/28/2010

Hi,
there are to ways:

  1. you can calculate and save new value in the separate field. In this case you can use JavaScript or PHP event to calculate this value.
  2. or you can calculate this value in the SQL query on the Edit SQL query tab. Here is just a sample:

select field1,

field2,

datediff(field1,field2) as days_diff,

...

from TableName



Then days_diff will be calculated automatically on the list page.