Skip to Content Skip to Menu

🕒 Save Time and Effort with CB Editor Assistant: Effortlessly create and refine content in Joomla 3, 4, & 5.
🎁 Limited Offer: Enjoy a 5-day FREE trial and save up to 30% afterward!

Displaying Age in Delimiter Fields

12 years 1 month ago - 12 years 1 month ago #216572 by edmundcheong
Displaying Age in Delimiter Fields was created by edmundcheong
I am trying to display age in delimter fields.

I already have cb_dateofbirth field which is set to display on profiles as "Age in years".

However when I create a delimiter field and place [cb_dateofbirth] in the delimiter field, i get the actual date of birth shown in "yyyy-mm-dd"

Is there a way I can display the age meaning that a way to code in the delimiter field such as:

[today's date] - [cb_dateofbirth] = age

User is ([today's date] - [cb_dateofbirth]) years old?


Just to tell you what I am trying to do so you can assist me better.

I am actually to do is to interpret age. For example:

[cb:if cb_dateofbirth=>"30" and cb_dateofbirth>="50"]Age is high risk.[/cb:if]

but because cb_dateofbirth is showing as date, I may have to use:

[cb:if cb_dateofbirth=>"1981-01-01" and cb_dateofbirth>="1951-01-01"]Age is high risk.[/cb:if]

If use the code above, i will need to change the dates either daily or yearly.

I hope you get what I mean.
Last edit: 12 years 1 month ago by edmundcheong.

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48709
  • Thanks: 8319
  • Karma: 1447
12 years 1 month ago #216606 by krileon
Replied by krileon on topic Re: Displaying Age in Delimiter Fields
Please see the below substitution usage tutorial.

www.allmysocials.com/directory/tutorials/item/233-substitution-usage

[FIELD_NAME] is always raw output, no formatting. For what you're wanting simply use the below.

[cb:userfield field="cb_dateofbirth" /]

As for IF statements you'll be comparing against the full date range and may need to use CB Query Field to query the database and calculate the age so you can use the age it self in your IF comparison.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in or Create an account to join the conversation.

12 years 1 month ago - 12 years 1 month ago #216609 by edmundcheong
Replied by edmundcheong on topic Re: Displaying Age in Delimiter Fields
Thanks! When I compare to a full date range, where joomla or cb store it's current date or time (system time)?

Second question, if I were to use auto action plugin, do I use the [cb:user field="cb_dateofbirth"] equal to function as a condition? Will it work?
Last edit: 12 years 1 month ago by edmundcheong.

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48709
  • Thanks: 8319
  • Karma: 1447
12 years 1 month ago #216627 by krileon
Replied by krileon on topic Re: Displaying Age in Delimiter Fields

When I compare to a full date range, where joomla or cb store it's current date or time (system time)?

Don't understand the question. CB/Joomla doesn't store current datetime anywhere. You can substitute current datetime using the below.

[cb:date format="PHP_DATE()_FORMAT" /]

Please see the below tutorial for further substitution usage information.

www.allmysocials.com/directory/tutorials/item/233-substitution-usage

Second question, if I were to use auto action plugin, do I use the [cb:user field="cb_dateofbirth"] equal to function as a condition?

Sure, if you want to condition on age instead of date.

Will it work?

Yes, it should.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.
The following user(s) said Thank You: edmundcheong

Please Log in or Create an account to join the conversation.

12 years 1 month ago #216816 by edmundcheong
Replied by edmundcheong on topic Re: Displaying Age in Delimiter Fields
Sort to bother you again. How do I trigger an auto action for cb_date = today? I would like to trigger an action if the stored date = today..

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48709
  • Thanks: 8319
  • Karma: 1447
12 years 1 month ago #216844 by krileon
Replied by krileon on topic Re: Displaying Age in Delimiter Fields
Configure your CB Auto Action as normally then supply the below conditional.

Conditional 1: [cb_date] Equal To [cb:date format="Y-m-d" /]

The above should do the trick.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.
The following user(s) said Thank You: edmundcheong

Please Log in or Create an account to join the conversation.

Moderators: beatnantkrileon
Powered by Kunena Forum