Rounding off to Nearst Integer Please Help Me...

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

Post Reply
devaraj4u
Participant
Posts: 32
Joined: Mon Nov 11, 2002 12:32 am
Location: Schaumburg,Chicago

Rounding off to Nearst Integer Please Help Me...

Post by devaraj4u »

Dear All,

In my project I am Subtracting 2 dates.I have ValueDate and MaturityDate So I m doing MaturityDate - ValueDate So that i will get difference in Days.My Business Requirement needs the difference in Months So what i did approxiately (MDATE - VDATE) / 30 So i m getting Difference in Months.But if u concern the output value it will be a Real/Decimal Value.

Example

ValueDate ---> 27/Feb/2003
MaturityDate ---> 27/Mar/2003

So (MDate - Vdate) ---> 28 Days (Diff in Days)
(MDate - Vdate)/30 ---> 0.93 (Diff in Months)...

I am getting the desired result as 0.93.
But the Need is,it need to be rouded off to the nearest interger.

Example

If the Range is like 0.5 To 0.99 it should rounded to 1.

In my case I need the output as '1' rather than 0.93 coz nearst integer is '1'

So I need the Function which will similar to Round() or CEIL() which is there in VB or Excel Tools.

I tried using INT() Function in DataStage it is simply truncating the decimal and returning me '0' for '0.9'.

Please can anybody help me...

Thanks & Regards,
K.S.Rajan.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Try INT(value+0.5) or OCONV(value, "MD0").
The second specifies "masked decimal, 0 decimal places, rounding". To get truncation it would be OCONV(value, "MD0T").


Ray Wurlod
Education and Consulting Services
ABN 57 092 448 518
devaraj4u
Participant
Posts: 32
Joined: Mon Nov 11, 2002 12:32 am
Location: Schaumburg,Chicago

Post by devaraj4u »

Dear Ray,

Thanks for your Timely Help.The Int(Value+0.5) worked well sir.

Thanks & Regars,
K.S.Rajan.
degraciavg
Premium Member
Premium Member
Posts: 39
Joined: Tue May 20, 2003 3:36 am
Location: Singapore

Post by degraciavg »

Hi Rajan,

Another altenative is to use the FMT() function, e.g.

FMT(DateDiff, 0)

Cheers,
Vladimir

vladimir
Post Reply