Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

How can i divide no of day by 365 and get answer in decimals?

ajay_sharma10
Participant
0 Kudos

i want to subtract two dates and then the answer must divide by 365 ..then i will get the experiance of person in the company ..

But the answer is comming

INTEGER ( WHERE RESULT VARIABLE IS TYPE P DECIMALS 3)

(E.G divide 458 / 365 = 1.000)

&

againg wrong answer (when result variable is type f )

1 ACCEPTED SOLUTION

peter_ruiz2
Active Contributor
0 Kudos

hi,

try this


data year type p value '365'.
data answer type p.

answer = 458 / year.

WRITE answer decimals 3.

regards,

Peter

Edited by: Peter Ruiz on Jul 22, 2008 5:23 PM

9 REPLIES 9

Former Member
0 Kudos

Hi,

DATA: work_exe TYPE p DECIMALS 4,

years TYPE f VALUE '+365',

days TYPE f VALUE '+458'.

work_exe = days / years.

WRITE work_exe.

Regards,

Sandeep

Former Member
0 Kudos

hi

use this Fm to calculate the dayes between two dates and then divide it by 365 .

SD_CALC_DURATION_FROM_DATETIME : Find the difference between two date/time and report the difference in hours

L_MC_TIME_DIFFERENCE : Find the time difference between two date/time

HR_99S_INTERVAL_BETWEEN_DATES : Difference between two dates in days, weeks, months

once u get the number of days after using any of this FM u only need to divide it by using DIV

Cheers

Snehi

Former Member
0 Kudos

Hi

Simply take it as Type i or declare a data type in se11.

Aditya

peter_ruiz2
Active Contributor
0 Kudos

hi,

try this


data year type p value '365'.
data answer type p.

answer = 458 / year.

WRITE answer decimals 3.

regards,

Peter

Edited by: Peter Ruiz on Jul 22, 2008 5:23 PM

0 Kudos

Friend the same thing i am doing ........ but answer comming is 1.000......

so first you execute it and then see wats answer is ....

0 Kudos

Hi,

I have written the code like this

DATA: v_temp TYPE P DECIMALS 3.

v_temp = 458 / 365.

write v_temp.

and the answer commins is- 1.255.

Regards,

Rajesh Akarte

former_member705122
Active Contributor
0 Kudos

Hi,

declare variable with type float or packed.

data: 
  result type p decimals 3.
 result = 458 / 365.
 WRITE result.

regards

Adil

0 Kudos

Hi ,

can u use FMs like this

FIMA_DAYS_AND_MONTHS_AND_YEARS

or

HR_SGPBS_YRS_MTHS_DAYS

regards

Prabhu

ajay_sharma10
Participant
0 Kudos

yes i go answer