Rounding down decimals

Database

Rounding down decimals

I have a very simple request. Rounding down to the full number.
For example I have a duration 0.9585, I want to show it as 0. If I have duration as 2.8505, I want to show it as 2.
5 REPLIES
Enthusiast

Re: Rounding down decimals

SELECT CAST(columnname as integer)
Senior Apprentice

Re: Rounding down decimals

This is called truncating, if it's up to 18 digits you can simply cast to a bigint:
select cast(x as bigint)

Or CAST(x - x MOD 1 AS DEC(38,0))

Dieter
Junior Supporter

Re: Rounding down decimals

Also, if you are in Teradata 14, you can use TRUNC() and ROUND() (Oracle heritage, I'm afraid ;-) )

Cheers.

Carlos.

Re: Rounding down decimals

thanks folks. you were very helpful. I am using teradata sql assistant for 12. 

Enthusiast

Re: Rounding down decimals

select substr('0.9585',1,1);

This will also work.