Skip to Content Skip to Menu

[SOLVED] Format Query Field result

  • bizguy
  • bizguy
  • OFFLINE
  • Posts: 199
  • Thanks: 32
  • Karma: 5
9 years 4 months ago - 9 years 4 months ago #266034 by bizguy
[SOLVED] Format Query Field result was created by bizguy
I have a Query field correctly pulling data from 2 databases and displaying the results in a multi-column field in a user profile tab.

Part of the query is SELECT ... (b.points-a.spoints)/10 AS people ... which correctly calculates the column value.

When the [column_people] is displayed in the field it is displayed as 27.0000 and what I am wondering is there some way to format the number display without the decimal and zeros?

Thanks

BTW
Joomla 3.4.1
CB 2.0.9
PHP 5.5.14
5.5.43-37.2 - Percona Server
Last edit: 9 years 4 months ago by krileon.

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48477
  • Thanks: 8281
  • Karma: 1443
9 years 4 months ago - 9 years 4 months ago #266061 by krileon
Replied by krileon on topic Format Query Field result
CB Query Field applies no formatting to it. The formatting is either in the database query results already or SQL is doing it. See the below documentation for numbers if you need to reformat it in your query.

dev.mysql.com/doc/refman/5.6/en/numeric-functions.html

More specifically you need to use the following to remove any decimal places.

Code:
TRUNCATE( ( ( b.`points` - a.`spoints` ) / 10 ), 0 ) AS people

You may want to round it though if you expect to have decimal values.


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: 9 years 4 months ago by krileon.
The following user(s) said Thank You: bizguy

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

  • bizguy
  • bizguy
  • OFFLINE
  • Posts: 199
  • Thanks: 32
  • Karma: 5
9 years 4 months ago #266075 by bizguy
Replied by bizguy on topic [solved] Format Query Field result
Kyle:

Thank you for the assistance once again. Based on your example, I realized I had failed to place a set of brackets around the total calculation, resulting in an error.

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

Moderators: beatnantkrileon
Powered by Kunena Forum