Skip to Content Skip to Menu

Query field to show date in year-month format

  • austega
  • austega
  • OFFLINE
  • Posts: 94
  • Thanks: 0
  • Karma: 1
10 years 8 months ago #240613 by austega
J2.5.16 CB1.9.1 CBS3.0.0

I want to create a field that shows the expiry date of the user's active subscription (when one exists) in year-month format (something like 2014-02). I have tried to use the query plugin to create this field but it refuses to appear on the designated profile tab (or throw any error messages).

I have attached a screen shot of the Query field configuration. It is my first use of the Query plugin and I am not experienced in SQL queries so I expect the issue is my understanding or execution. The query I am currently using (I have tried others unsuccessfully!) is:

SELECT DATE_FORMAT(`expiry_date`,'%Y-%m') FROM `sag13_cbsubs_subscriptions` WHERE `user_id` = '[user_id]' AND `status` = 'A';

Attachments:

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48477
  • Thanks: 8281
  • Karma: 1443
10 years 8 months ago #240658 by krileon
Replied by krileon on topic Query field to show date in year-month format
Seams to work fine in my tests. Replace the table prefix though so Joomla can replace it automatically. Try the below.

Code:
SELECT DATE_FORMAT( `expiry_date`, '%Y-%m' ) FROM `#__cbsubs_subscriptions` WHERE `user_id` = '[user_id]' AND `status` = 'A';

Ensure the CB Query Field plugin it self is also enabled within CB > Plugin Management.


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.

  • austega
  • austega
  • OFFLINE
  • Posts: 94
  • Thanks: 0
  • Karma: 1
10 years 8 months ago #240893 by austega
Replied by austega on topic Query field to show date in year-month format
Thanks Kyle.

Still didn't show - no error or field title either. But your assurance that my query was OK pointed me to try other things.

I was testing this in the backend view and the culprit seemed to be that I had the field's Location | Profile Edit set as the default Disabled. Changing this to Enabled showed the field (and correct value). I gather that the backend view which has edit functionality is affected by this setting.

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

  • austega
  • austega
  • OFFLINE
  • Posts: 94
  • Thanks: 0
  • Karma: 1
10 years 8 months ago #240894 by austega
Replied by austega on topic Query field to show date in year-month format
What is a little funny and a little sad is that now I have this working, I find that the generated data is not stored in the database as i assumed (but probably calculated on the fly). I wanted this field to allow grouping by it in Fabrik's report generator. It seems I need to work out how to generate it on the fly within Fabrik!

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48477
  • Thanks: 8281
  • Karma: 1443
10 years 8 months ago #240913 by krileon
Replied by krileon on topic Query field to show date in year-month format
Query fields don't store anything. They query the database and output the results. So you won't be able to do userlist filtering or anything of the sort on a query field.


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.

Moderators: beatnantkrileon
Powered by Kunena Forum