Rounding off to Nearst Integer Please Help Me...
Posted: Fri Jul 25, 2003 12:24 am
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.
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.