Calculate Contact age in a Drupal viewCustom Case Fields do not work in Drupal ViewsDisplay CiviCRM Price Set...

Placing an adverb between a verb and an object?

Can a person refuse a presidential pardon?

A starship is travelling at 0.9c and collides with a small rock. Will it leave a clean hole through, or will more happen?

Am I a Rude Number?

Can an insurance company drop you after receiving a bill and refusing to pay?

What is the wife of a henpecked husband called?

How to deal with an incendiary email that was recalled

Is there some relative to Dutch word "kijken" in German?

What is the purpose of easy combat scenarios that don't need resource expenditure?

How to avoid Replace substituting subscripts?

Does fast page mode apply to ROM?

What is better: yes / no radio, or simple checkbox?

What flying insects could re-enter the Earth's atmosphere from space without burning up?

Strange Sign on Lab Door

How to prevent users from executing commands through browser URL

How can animals be objects of ethics without being subjects as well?

If I sold a PS4 game I owned the disc for, can I reinstall it digitally?

How to acknowledge an embarrassing job interview, now that I work directly with the interviewer?

Contest math problem about crossing out numbers in the table

Why are the books in the Game of Thrones citadel library shelved spine inwards?

Why does String.replaceAll() work differently in Java 8 from Java 9?

Program that converts a number to a letter of the alphabet

Dilemma of explaining to interviewer that he is the reason for declining second interview

How should I handle players who ignore the session zero agreement?



Calculate Contact age in a Drupal view


Custom Case Fields do not work in Drupal ViewsDisplay CiviCRM Price Set end date in viewUsing CiviCRM API in Drupal ViewHow to create Drupal view to show CiviEvents and Drupal EventsTags for contact in drupal view shown on separate rowsHow to display multi day events in drupal calendar view?Show Activity Source Contact in a Drupal ViewCan we expose the membership description field within a Drupal Viewcustom fields not adding to Drupal viewsCiviCRM-Entity Case - view block on a Drupal node













2















I'm exposing civi contact data in a drupal view. I can expose date of birth, but not the contact age field.



Anyone know of a module/ combination of modules that will allow me to calculate age in years within the view?










share|improve this question



























    2















    I'm exposing civi contact data in a drupal view. I can expose date of birth, but not the contact age field.



    Anyone know of a module/ combination of modules that will allow me to calculate age in years within the view?










    share|improve this question

























      2












      2








      2








      I'm exposing civi contact data in a drupal view. I can expose date of birth, but not the contact age field.



      Anyone know of a module/ combination of modules that will allow me to calculate age in years within the view?










      share|improve this question














      I'm exposing civi contact data in a drupal view. I can expose date of birth, but not the contact age field.



      Anyone know of a module/ combination of modules that will allow me to calculate age in years within the view?







      drupal-views






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked 16 hours ago









      Craig AlmondCraig Almond

      542313




      542313






















          2 Answers
          2






          active

          oldest

          votes


















          5














          In your view, pull in the CiviCRM birth date field.
          Under date format, select Time ago
          This will present the B.O.B. field as 40 years 7 months



          enter image description here



          To remove years and months from the output you can ‘Rewrite results’ in the view and ‘Trim this field to a maximum length’ and set ‘Maximum length’ to 2 characters






          share|improve this answer
























          • Absolutely Awesome. Thank you Anil

            – Craig Almond
            14 hours ago



















          1














          You need to add views php module



          Add the dob into a view. In this example called birth_date



          Add a global php field.



          Then put this code into the output code box in the global php field



          <?php 
          $ageTime = $row->birth_date;
          $t = time();
          $age = $t-$ageTime;
          $year = 60 * 60 * 24 * 365;
          $ageYears = $age / $year;
          print floor($ageYears);
          ?>





          share|improve this answer
























          • Thanks Tony. Anil's suggestion has worked a charm. So I haven't needed to dabble with PHP

            – Craig Almond
            14 hours ago











          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "605"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          noCode: true, onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcivicrm.stackexchange.com%2fquestions%2f28721%2fcalculate-contact-age-in-a-drupal-view%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          2 Answers
          2






          active

          oldest

          votes








          2 Answers
          2






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          5














          In your view, pull in the CiviCRM birth date field.
          Under date format, select Time ago
          This will present the B.O.B. field as 40 years 7 months



          enter image description here



          To remove years and months from the output you can ‘Rewrite results’ in the view and ‘Trim this field to a maximum length’ and set ‘Maximum length’ to 2 characters






          share|improve this answer
























          • Absolutely Awesome. Thank you Anil

            – Craig Almond
            14 hours ago
















          5














          In your view, pull in the CiviCRM birth date field.
          Under date format, select Time ago
          This will present the B.O.B. field as 40 years 7 months



          enter image description here



          To remove years and months from the output you can ‘Rewrite results’ in the view and ‘Trim this field to a maximum length’ and set ‘Maximum length’ to 2 characters






          share|improve this answer
























          • Absolutely Awesome. Thank you Anil

            – Craig Almond
            14 hours ago














          5












          5








          5







          In your view, pull in the CiviCRM birth date field.
          Under date format, select Time ago
          This will present the B.O.B. field as 40 years 7 months



          enter image description here



          To remove years and months from the output you can ‘Rewrite results’ in the view and ‘Trim this field to a maximum length’ and set ‘Maximum length’ to 2 characters






          share|improve this answer













          In your view, pull in the CiviCRM birth date field.
          Under date format, select Time ago
          This will present the B.O.B. field as 40 years 7 months



          enter image description here



          To remove years and months from the output you can ‘Rewrite results’ in the view and ‘Trim this field to a maximum length’ and set ‘Maximum length’ to 2 characters







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered 14 hours ago









          Anil - MillerTechAnil - MillerTech

          99818




          99818













          • Absolutely Awesome. Thank you Anil

            – Craig Almond
            14 hours ago



















          • Absolutely Awesome. Thank you Anil

            – Craig Almond
            14 hours ago

















          Absolutely Awesome. Thank you Anil

          – Craig Almond
          14 hours ago





          Absolutely Awesome. Thank you Anil

          – Craig Almond
          14 hours ago











          1














          You need to add views php module



          Add the dob into a view. In this example called birth_date



          Add a global php field.



          Then put this code into the output code box in the global php field



          <?php 
          $ageTime = $row->birth_date;
          $t = time();
          $age = $t-$ageTime;
          $year = 60 * 60 * 24 * 365;
          $ageYears = $age / $year;
          print floor($ageYears);
          ?>





          share|improve this answer
























          • Thanks Tony. Anil's suggestion has worked a charm. So I haven't needed to dabble with PHP

            – Craig Almond
            14 hours ago
















          1














          You need to add views php module



          Add the dob into a view. In this example called birth_date



          Add a global php field.



          Then put this code into the output code box in the global php field



          <?php 
          $ageTime = $row->birth_date;
          $t = time();
          $age = $t-$ageTime;
          $year = 60 * 60 * 24 * 365;
          $ageYears = $age / $year;
          print floor($ageYears);
          ?>





          share|improve this answer
























          • Thanks Tony. Anil's suggestion has worked a charm. So I haven't needed to dabble with PHP

            – Craig Almond
            14 hours ago














          1












          1








          1







          You need to add views php module



          Add the dob into a view. In this example called birth_date



          Add a global php field.



          Then put this code into the output code box in the global php field



          <?php 
          $ageTime = $row->birth_date;
          $t = time();
          $age = $t-$ageTime;
          $year = 60 * 60 * 24 * 365;
          $ageYears = $age / $year;
          print floor($ageYears);
          ?>





          share|improve this answer













          You need to add views php module



          Add the dob into a view. In this example called birth_date



          Add a global php field.



          Then put this code into the output code box in the global php field



          <?php 
          $ageTime = $row->birth_date;
          $t = time();
          $age = $t-$ageTime;
          $year = 60 * 60 * 24 * 365;
          $ageYears = $age / $year;
          print floor($ageYears);
          ?>






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered 14 hours ago









          Tony HorrocksTony Horrocks

          71738




          71738













          • Thanks Tony. Anil's suggestion has worked a charm. So I haven't needed to dabble with PHP

            – Craig Almond
            14 hours ago



















          • Thanks Tony. Anil's suggestion has worked a charm. So I haven't needed to dabble with PHP

            – Craig Almond
            14 hours ago

















          Thanks Tony. Anil's suggestion has worked a charm. So I haven't needed to dabble with PHP

          – Craig Almond
          14 hours ago





          Thanks Tony. Anil's suggestion has worked a charm. So I haven't needed to dabble with PHP

          – Craig Almond
          14 hours ago


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to CiviCRM Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcivicrm.stackexchange.com%2fquestions%2f28721%2fcalculate-contact-age-in-a-drupal-view%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          is 'sed' thread safeWhat should someone know about using Python scripts in the shell?Nexenta bash script uses...

          How do i solve the “ No module named 'mlxtend' ” issue on Jupyter?

          Pilgersdorf Inhaltsverzeichnis Geografie | Geschichte | Bevölkerungsentwicklung | Politik | Kultur...