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: 

FM to get the number of days in Year,month and days by giving number of day

Former Member
0 Kudos
4,083

Hi ALL,

This is quit differnt.

I need to give input the 'start date' and the 'number of days' and get the total days from the start date in year,month and day format.

for example.

start date :01.01.2009

number of days as 32

then i should get

years:0

months :1

days :1

Pleas help me out.

1 ACCEPTED SOLUTION

Former Member
0 Kudos
693

hi,

please SEARCH forum

use 'HR_99S_DATE_ADD_SUB_DURATION'

IM_DATE - provide your input date

IM_OPERATOR - This one is whether you want to add/sub from your date " + / - "

IM_DURATION - Duration means How many years/months/days you want to add/sub

or 'J_1H_CAL_DATE_IN_INTERVAL'

thanks

8 REPLIES 8

Former Member
0 Kudos
693

Use the FM HR_99S_DATE_ADD_SUB_DURATION.

This should help

0 Kudos
693

Try using this code and see if this helps the requirement.

DATA: w_durdd type PSEN_DURATION, w_datein type sy-datum, w_dateout type sy-datum, MOVE 32 TO w_durdd-durdd. CALL FUNCTION 'HR_99S_DATE_ADD_SUB_DURATION' EXPORTING im_date = w_datein im_operator = '+' im_duration = w_durdd IMPORTING EX_DATE = w_dateout.

Former Member
0 Kudos
693

Hi ,

use this function module 'HR_99S_DATE_ADD_SUB_DURATION' .

Please let me know if you still have any issues on this.

Thansk and regards,

Rajeshwar.

Former Member
0 Kudos
694

hi,

please SEARCH forum

use 'HR_99S_DATE_ADD_SUB_DURATION'

IM_DATE - provide your input date

IM_OPERATOR - This one is whether you want to add/sub from your date " + / - "

IM_DURATION - Duration means How many years/months/days you want to add/sub

or 'J_1H_CAL_DATE_IN_INTERVAL'

thanks

Former Member
0 Kudos
693

Hello

Use FM HR_SEN_CRULE_0100_DURATION, where begin date = your start date and end date = your start date + number of days.

0 Kudos
693

with ref to Maroz post ...

FM works

ex


parameters:pa_dat type sy-datum.
parameters:pa_days type i.

data:v_dat type sy-datum.
data:output type PSEN_DURATION_DEC.

v_dat = pa_dat + pa_days.

CALL FUNCTION 'HR_SEN_CRULE_0100_DURATION'
  EXPORTING
    id_begda                       = pa_dat
    id_endda                       = v_dat
 IMPORTING
   ES_DURATION                     = output
 EXCEPTIONS
   CONVERSION_NOT_SPECIFIED       = 1
   CONVERSION_NOT_POSSIBLE        = 2
   OTHERS                         = 3
          .
IF sy-subrc <> 0.
 MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
else.
  write:/ 'Years', output-CALYY  DECIMALS 0,
        / 'Months', output-CALMM DECIMALS 0,
        /'Days', output-CALDD    DECIMALS 0.
ENDIF.

Former Member
0 Kudos
693

Hi,

Please use following FM,

CALL FUNCTION 'HR_99S_INTERVAL_BETWEEN_DATES'

EXPORTING

BEGDA = " Enter Start Date"

endda = " Enter Start Date + Number of day (i.e. in your case 32) = End Date

TAB_MODE = ' '

IMPORTING

DAYS = " No Of days between Start and End Date

C_WEEKS = " No Of weeks between Start and End Date

C_MONTHS = " No Of Months between Start and End Date

C_YEARS = " No Of Years between Start and End Date

WEEKS =

MONTHS =

YEARS =

D_MONTHS =

MONTH_TAB =

.

Thanks and Regards,

ShreeMohan

Former Member
0 Kudos
693

hi Anusha,

first u pass the date and the days to the following fm you will get the result date....

data:date type sy-datum,

r_date(10) type c.

date = sy-datum.

CALL FUNCTION 'CALCULATE_DATE'

EXPORTING

DAYS = '32'

MONTHS = '0'

START_DATE = date

IMPORTING

RESULT_DATE = r_date

.

write:/ r_date.

then you need to pass the result date and the date to the following fm to get the required output...

CALL FUNCTION 'HR_HK_DIFF_BT_2_DATES'

EXPORTING

date1 = r_date

date2 = date

IMPORTING

years = v_years

months = v_months

days = v_days

EXCEPTIONS

invalid_dates_specified = 1

OTHERS = 2.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

here u will get the difference in days, months and year...

i hope u wil get help from this...

regards

Ashu Singh