Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.
Moderators: chulett, rschirm, roy
-
Datamine
- Premium Member
![Premium Member Premium Member](./images/ranks/premium.gif)
- Posts: 8
- Joined: Wed Jun 21, 2006 7:26 am
Post
by Datamine »
Hello Everyone,
I've tried to find it here but without luck, so here is my question,
i want to "trunc" a decimal number up to the 3rd position after the decimal separator, i don't want to round the number.
for example:
i have a decimal number --> 1785.65897
and i want the result to be --> 1785.658
what is the simplest why to accomplish it in Datastage?
thanks,
Datamine
Malam BI
-
dganeshm
- Premium Member
![Premium Member Premium Member](./images/ranks/premium.gif)
- Posts: 91
- Joined: Tue Aug 11, 2009 3:26 pm
Post
by dganeshm »
Two ways :
Change the precision of the decimal to n,3
Treat as a string , do a substring from 1 to index of 1st occurence of '.' + 3.
Regards,
Ganesh
-
gaya3
- Participant
- Posts: 42
- Joined: Wed Jun 08, 2005 12:34 am
Post
by gaya3 »
you can use the oconv format function for decimal conversions.
Oconv(1234.567, "MD20T") will give 1234.56 without rounding off. Replace '2' in MD20T with the number of decimal places that you want in your output.
-
Datamine
- Premium Member
![Premium Member Premium Member](./images/ranks/premium.gif)
- Posts: 8
- Joined: Wed Jun 21, 2006 7:26 am
Post
by Datamine »
o.k - thanks for the info,
can i also use the function FMT?
Malam BI
-
ArndW
- Participant
- Posts: 16318
- Joined: Tue Nov 16, 2004 9:08 am
- Location: Germany
-
Contact:
Post
by ArndW »
I prefer "INT(In.NumberColumn/1000)*1000" to get 3 decimal positions.
-
Datamine
- Premium Member
![Premium Member Premium Member](./images/ranks/premium.gif)
- Posts: 8
- Joined: Wed Jun 21, 2006 7:26 am
Post
by Datamine »
from a performance point of view, which one of the method mentioned above is the fastest?
Malam BI
-
ray.wurlod
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
-
Contact:
Post
by ray.wurlod »
I believe that, of the options listed, Fmt() would be most efficient.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.