Skip to Content Skip to Menu

🎃 Happy Halloween! Treat yourself with an awesome discount on memberships! Get 20% off now with code SPOOKY-2024!

[SOLVED] Show value or field with date condition

11 years 8 months ago - 11 years 8 months ago #220849 by deltafidesign
I would show the zodiacal sign for every user according to his/her birth date.

First I could create 12 fields, one for every sign, or I can create just one delimiter with 12 signs value and filter them with cb substitutions (if).

Now is it possible to set the condition on the range period for every zodiacal sign to show the correct sign?
Last edit: 11 years 8 months ago by deltafidesign.

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48457
  • Thanks: 8280
  • Karma: 1443
11 years 8 months ago #220870 by krileon
Replied by krileon on topic Show value or field with date condition
You'll probably want to use CB Query Field to first just return the day and month of their birthdate field as CB stores year for date fields and that'll cause your IF substitutions to be a nightmare to get working. Then you can use multiple checks in your IF substitution like the below example.

[cb:if cb_birthday>="06-21" && cb_birthday<="07-22"]Cancer[/cb:if]


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.

11 years 8 months ago #220882 by deltafidesign
Replied by deltafidesign on topic Show value or field with date condition
I'm trying to biuld the SQL query to extract only %m-%d but I cannot do it. Would you help me with the query please.

Thanks.

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48457
  • Thanks: 8280
  • Karma: 1443
11 years 8 months ago #220886 by krileon
Replied by krileon on topic Show value or field with date condition
Please see the below MYSQL documentation.

dev.mysql.com/doc/refman/5.6/en/date-and-time-functions.html#function_date-format

Examples of the functions usage are already included with the DATE_FORMAT documentation. Example as follows with CB Query Field.
Code:
SELECT DATE_FORMAT( `cb_birthdate`, '%m-%d' ) FROM `#__comprofiler` WHERE `user_id` = '[user_id]'


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.

11 years 8 months ago - 11 years 8 months ago #220893 by deltafidesign
Replied by deltafidesign on topic Show value or field with date condition
Oh right! I made a mistake in the query... it was syntactic correct except for the `cb_birthdate` where I used ' instead of `

Now the query fields give me only month-day value, but then the substitution you suggested me doesn't work:

[cb:if cb_querydata>="01-01" && cb_querydata<="01-20"]
<div class="zodiac-sign">
<img alt="Capricorno" src="images/icons/capricorno.png" height="128" width="128" />
<p>Capricorno</p>
</div>
[/cb:if]

Could this 'caused by the fact that CBQuery field do not store data in DB?
Last edit: 11 years 8 months ago by deltafidesign.

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48457
  • Thanks: 8280
  • Karma: 1443
11 years 8 months ago - 11 years 8 months ago #220897 by krileon
Replied by krileon on topic Show value or field with date condition

Could this 'caused by the fact that CBQuery field do not store data in DB?

Shouldn't matter with CB 1.9 as we updated it to use getFields API so calculated fields can be used. Add the field substitution (e.g. [cb_querydata]) to a delimiter field to test that it's outputting properly. Also try using "and" instead of "&&".


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.
Last edit: 11 years 8 months ago by krileon.

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

Moderators: beatnantkrileon
Powered by Kunena Forum