Skip to Content Skip to Menu

[SOLVED] Request with TO_DAYS(CURRENT_TIMESTAMP)

  • chanteur94
  • chanteur94
  • OFFLINE
  • Posts: 302
  • Thanks: 13
  • Karma: 1
9 years 7 months ago - 9 years 7 months ago #261772 by chanteur94
Hi
I create a cb field query to test if a user have visited a profil after 1 day (return 0 or 1)

( SELECT  COUNT(*) FROM `#__comprofiler_views` AS v WHERE v.`profile_id`= '[user_id]' AND v.`viewer_id` = '[cb:userdata field="user_id" user="#me" /]' AND (TO_DAYS(current_timestamp) - TO_DAYS(v.`lastview`)) > 0)

This work on PhpMyAdmin but not in my cb query.

Any help ?

Thank you.
Last edit: 9 years 7 months ago by krileon.

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48478
  • Thanks: 8282
  • Karma: 1443
9 years 7 months ago #261790 by krileon
Replied by krileon on topic Request with TO_DAYS(CURRENT_TIMESTAMP)
There's no way that 1:1 works in phpMyAdmin due to the prefix and substitution which neither would process in phpMyAdmin. The below example provides the flexibility of telling you how many days since the users last visit.

Code:
SELECT DATEDIFF( NOW(), `lastview` ) FROM `#__comprofiler_views` WHERE `profile_id` = '[user_id]' AND `viewer_id` = '[cb:userdata field="user_id" user="#me" /]'

Example results as follows.

Date: 2015-03-09 14:31:30
Difference: 23 Days
Result: 23

Please understand we do not provide custom coding here. We are not here to write custom code or debug your custom coding for you. I've already informed you of this multiple times. Future requests will be ignored or deleted. We've no issues providing simple examples to get you started, but we're not here to provide you with specific code.

When using a plugin like CB Query Field which simply sends your string through SQL you are expected to debug your own code. It's simply a tool to pass your string along to MYSQL functions and nothing more; it not functioning is guaranteed to be a problem with the query directly. As always be sure debug mode and maximum error reporting is set in Joomla global configuration while testing so you can see error output if the query should fail as well as allows you to debug the query being sent to MYSQL in Joomlas debug display at the bottom of the page.

If you need custom coding you should consult with a contract developer as needed.


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.

  • chanteur94
  • chanteur94
  • OFFLINE
  • Posts: 302
  • Thanks: 13
  • Karma: 1
9 years 7 months ago #261801 by chanteur94
Replied by chanteur94 on topic Request with TO_DAYS(CURRENT_TIMESTAMP)
Hi Kyle.

Thank you for all these informations.

I will try to not disturb you with questions about coding.

I have just purchase CBSub and I probably will have some questions :-)

PS : when I say that it works in PhpMyadmin, I haven't specify that I change the substitution (I'm not so stupid :-)

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

Moderators: beatnantkrileon
Powered by Kunena Forum