Calculate Contact age in a Drupal viewCustom Case Fields do not work in Drupal ViewsDisplay CiviCRM Price Set...
How can I install sudo without using su?
Why avoid shared user accounts?
SQL Server 2017 - Temporal table issues
Can a person refuse a presidential pardon?
How would an AI self awareness kill switch work?
How can animals be objects of ethics without being subjects as well?
Cryptic with missing capitals
How do I say "Brexit" in Latin?
How should I handle players who ignore the session zero agreement?
How do you funnel food off a cutting board?
Word or phrase for showing great skill at something without formal training in it
Indirectly access environment variable
Why did the villain in the first Men in Black movie care about Earth's Cockroaches?
It took me a lot of time to make this, pls like. (YouTube Comments #1)
Using only 1s, make 29 with the minimum number of digits
How to avoid being sexist when trying to employ someone to function in a very sexist environment?
How can my powered armor quickly replace its ceramic plates?
What to do when being responsible for data protection in your lab, yet advice is ignored?
Does Windows 10's telemetry include sending *.doc files if Word crashed?
What is the purpose of easy combat scenarios that don't need resource expenditure?
Why do members of Congress in committee hearings ask witnesses the same question multiple times?
What makes the Forgotten Realms "forgotten"?
Would a National Army of mercenaries be a feasible idea?
Is there any differences between "Gucken" and "Schauen"?
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 2 hours ago
Craig AlmondCraig Almond
537313
537313
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
23 mins 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
21 mins 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
23 mins 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
23 mins 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 31 mins ago
Anil - MillerTechAnil - MillerTech
97818
97818
Absolutely Awesome. Thank you Anil
– Craig Almond
23 mins ago
add a comment |
Absolutely Awesome. Thank you Anil
– Craig Almond
23 mins ago
Absolutely Awesome. Thank you Anil
– Craig Almond
23 mins ago
Absolutely Awesome. Thank you Anil
– Craig Almond
23 mins 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
21 mins 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
21 mins 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 37 mins 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
21 mins ago
add a comment |
Thanks Tony. Anil's suggestion has worked a charm. So I haven't needed to dabble with PHP
– Craig Almond
21 mins ago
Thanks Tony. Anil's suggestion has worked a charm. So I haven't needed to dabble with PHP
– Craig Almond
21 mins ago
Thanks Tony. Anil's suggestion has worked a charm. So I haven't needed to dabble with PHP
– Craig Almond
21 mins 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