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
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
add a comment |
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
add a comment |
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
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
drupal-views
asked 16 hours ago
Craig AlmondCraig Almond
542313
542313
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
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
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
Absolutely Awesome. Thank you Anil
– Craig Almond
14 hours ago
add a comment |
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);
?>
Thanks Tony. Anil's suggestion has worked a charm. So I haven't needed to dabble with PHP
– Craig Almond
14 hours ago
add a comment |
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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
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
Absolutely Awesome. Thank you Anil
– Craig Almond
14 hours ago
add a comment |
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
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
Absolutely Awesome. Thank you Anil
– Craig Almond
14 hours ago
add a comment |
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
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
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
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
answered 14 hours ago
Anil - MillerTechAnil - MillerTech
99818
99818
Absolutely Awesome. Thank you Anil
– Craig Almond
14 hours ago
add a comment |
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
add a comment |
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);
?>
Thanks Tony. Anil's suggestion has worked a charm. So I haven't needed to dabble with PHP
– Craig Almond
14 hours ago
add a comment |
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);
?>
Thanks Tony. Anil's suggestion has worked a charm. So I haven't needed to dabble with PHP
– Craig Almond
14 hours ago
add a comment |
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);
?>
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);
?>
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
add a comment |
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
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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