drupal views difference between two dates

1.6k views Asked by At

I want to create a view in which there are two fields start date and end date. I want to display one more field that is (difference between the start date and end date). All this three fields should be displayed in table format. So please tell me how to find difference between two dates using views?And i want to display this difference between the date fields as third column of the table.

1

There are 1 answers

0
Florian Motteau On

You can try with Computed Fields. It allows you to define a new dynamic field for any content type (stored in database or computed on the fly), and you can code in PHP the value for this field, using other fields values.

Creating a computed field to store two dates fields difference is one of the example in the module doc :

https://www.drupal.org/node/149234

Then in your view you just have to display the computed field (and the two original fields).

Views PHP can do the trick as well, it allows you to create a new field within a view, which will be computed in PHP. You can use other fields values to calculate its value.

But I would recommend Computed Fields, Views PHP can be a performance killer.

Good luck