Is it possible to calculate date in Views like to calculate two cell using global math for this case?


  • Nick's birth of date was 20/10/2005
  • Only 20 years old can join the club
  • So before 31/10/2025 Nick cannot join the club, its mean Nick needs to wait for 10 years 10 days (date 31/10/2025) to join the club.

Can anyone assist me to solve this?

2 Answers 2


You can try Views PHP which allows you to add a php code field to a View.

Otherwise, for a less "dangerous" solution, you can add a field to your content type for which you are creating the View, hide the field from the node creation form with css, hook_form_alter() or Display Suite, and create a Rule that calculates the new date when a user save new content. This field could be a Date field, or an Interval field if you want to store the interval between two dates.

  • Someone is being really "funny" down-voting all my answers tonight for no reason and with no explanation. Thanks guys!
    – argiepiano
    Commented Nov 11, 2015 at 5:28
  • 1
    Don't worry too much about some downvotes so now and then ... Commented Nov 11, 2015 at 6:23

Have a look at the Computed Field module. You can use it to define a new dynamic field for any content type, which can either be stored in the database or computed on the fly. Some more details about this module (from its project page):

Computed Field is a very powerful field module that lets you add a custom "computed fields" to your content types. These computed fields are populated with values that you define via PHP code. You may draw on anything available to Drupal, including other fields, the current user, database tables, you name it. (Feeling the power yet? :) ) You can also choose whether to store your computed field values in the database with other content fields, or have them "calculated" on the fly during node views. (Although you should note that Views use requires database stored values.) This field is literally the Swiss Army knife of fields. So start cooking up your PHP based values!

You may also want to look at its Community documentation, especially its child page about "Calculating a duration given a start and end time", here is a quote from it:

... create a new computed field to calculate the duration as a decimal number of hours (where 1.5 is 1 hour and 30 minutes).

PS: not 100% sure if it would apply in this case, but for a possible alternative to the Views PHP module (as suggested in another answer here), you may want to use an approach as explained in "44,497 People Are Wrong: How to NEVER Need Views PHP".

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.