All Forums Database
aodabasio 2 posts Joined 03/13
05 Mar 2013
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.

KS42982 137 posts Joined 12/12
05 Mar 2013

SELECT CAST(columnname as integer)

dnoeth 4628 posts Joined 11/04
05 Mar 2013

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

Dieter

CarlosAL 512 posts Joined 04/08
06 Mar 2013

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

aodabasio 2 posts Joined 03/13
06 Mar 2013

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

kumar_abhilash 15 posts Joined 04/14
27 Apr 2014

select substr('0.9585',1,1);
This will also work.

You must sign in to leave a comment.