[Solved] RoundUp Function

Discuss the database features

[Solved] RoundUp Function

Postby gkick » Tue Sep 03, 2019 6:09 am

Hi,

The Round Function in HSQL 2.5 rounds up or down to the left or right based on .5
How can I round any decimal value of a numeric field up to an integer, so that 45.3 turns into 46 etc?
Any possibility of sucking up CALCs roundup function?
see attached image, thanks
Attachments
rounding.JPG
Last edited by gkick on Tue Sep 03, 2019 7:16 am, edited 1 time in total.
Libre Office 6.2 on Windows 10 HSQL 2.5 backend
gkick
 
Posts: 172
Joined: Wed Aug 07, 2019 5:24 pm
Location: Chile

Re: RoundUp Function

Postby Sliderule » Tue Sep 03, 2019 7:00 am

  1. Please check out HSQL Built-In Functions:

    http://www.hsqldb.org/doc/2.0/guide/builtinfunctions-chapt.html


  2. Please see the documentation for the Numeric Functions:

    http://www.hsqldb.org/doc/2.0/guide/builtinfunctions-chapt.html#bfc_numeric_functions

    http://www.hsqldb.org/doc/2.0/guide/builtinfunctions-chapt.html#bfc_numeric_functions wrote:
    CEILING

    { CEIL | CEILING } ( <num value expr> )

    Returns the smallest integer greater than or equal to the argument. If the argument is exact numeric then the result is exact numeric with a scale of 0. If the argument is approximate numeric, then the result is of DOUBLE type. (JDBC and Foundation)
Therefore, see examples below to answer your question.

Code: Select all   Expand viewCollapse view
CEILING(45.3)


Code: Select all   Expand viewCollapse view
CEILING("MY_TALBE"."MY_NUMERIC_COLUMN")


I hope this helps, please be sure to let me / us know.

Sliderule

Thanks to add [Solved] in your 1st post Subject (edit button top right) if this issue has been resolved.
User avatar
Sliderule
Volunteer
 
Posts: 1196
Joined: Thu Nov 29, 2007 9:46 am

Re: RoundUp Function

Postby gkick » Tue Sep 03, 2019 7:15 am

Thanks a lot Sliderule, put the AGE_Float function to work as well

CEILING(AGE_FLOAT( [tblContacts].[DateOfBirth], CURRENT_DATE )) Would never have thought to look for ceiling
Libre Office 6.2 on Windows 10 HSQL 2.5 backend
gkick
 
Posts: 172
Joined: Wed Aug 07, 2019 5:24 pm
Location: Chile

Re: RoundUp Function

Postby Sliderule » Tue Sep 03, 2019 2:44 pm

gkick wrote:Would never have thought to look for ceiling

That is exactly why I pointed you the HTML version of the HSQL database back-end documentation.

Likewise, you downloaded the PDF Version, as a part of HSQL download . . . in the doc -> guide directory, with file name guide.pdf.

For others reading this forum post . . . another similar function is FLOOR

http://www.hsqldb.org/doc/2.0/guide/builtinfunctions-chapt.html#bfc_numeric_functions wrote:
FLOOR

FLOOR ( <num value expr> )

Returns the largest integer that is less than or equal to the argument. If the argument is exact numeric then the result is exact numeric with a scale of 0. If the argument is approximate numeric, then the result is of DOUBLE type. (JDBC
and Foundation)

Sliderule
User avatar
Sliderule
Volunteer
 
Posts: 1196
Joined: Thu Nov 29, 2007 9:46 am


Return to Base

Who is online

Users browsing this forum: No registered users and 4 guests