Application Development and Automation 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: 
Read only

reduce one month from date value

former_member227140
Active Participant
0 Likes
4,586

Hello all,

i have one simple doubt .....

if i have these

s_ddate-sign = 'I'.

s_ddate-option = 'BT'.

s_ddate-low = date_low.

s_ddate-high = date_high.

APPEND s_ddate.

CLEAR s_ddate.

where date_low and date_high are values which ar coming from user input (import parameter)

now i define these two variables

date_low1

date_high1

now i want that date_low1 value should be exactly one month less to date_low

and date_high1 value exacttly one month less to date_high

how can i get this...

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
3,129

Hi,

Extract the month from the date_low, subtract 1 from it and contenate them again and save the result in date_low1.

Same thing for the date_high .

eg:

date_low=12/13/2009
month = date_low + 0(2).
date1 = date_low + 2(8).
month = month - 1.
concatenate month date1 into date_low1.

hope this might solve your problem.

Pooja

Hello all,

i have one simple doubt .....

if i have these

s_ddate-sign = 'I'.

s_ddate-option = 'BT'.

s_ddate-low = date_low.

s_ddate-high = date_high.

APPEND s_ddate.

CLEAR s_ddate.

where date_low and date_high are values which ar coming from user input (import parameter)

now i define these two variables

date_low1

date_high1

now i want that date_low1 value should be exactly one month less to date_low

and date_high1 value exacttly one month less to date_high

how can i get this...

5 REPLIES 5
Read only

Former Member
0 Likes
3,129

Hi,

Use FM HRAR_SUBTRACT_MONTH_TO_DATE. This FM take the date as input and return a date that is exactly one month less than the input date.


CALL FUNCTION 'HRAR_SUBTRACT_MONTH_TO_DATE'
  EXPORTING
    date                      = s_ddate-low
 IMPORTING
   DATE_MINUS_ONE_MONTH       = date_low1
          .

Regards,

Bhavesh.

Read only

Former Member
0 Likes
3,130

Hi,

Extract the month from the date_low, subtract 1 from it and contenate them again and save the result in date_low1.

Same thing for the date_high .

eg:

date_low=12/13/2009
month = date_low + 0(2).
date1 = date_low + 2(8).
month = month - 1.
concatenate month date1 into date_low1.

hope this might solve your problem.

Pooja

Read only

Former Member
0 Likes
3,129

Hi,

You can achieve by..


LOOP at S_DATE.
  S_DATE-LOW = S_DATE-LOW - 30.
S_DATE-HIGH = S_DATE-HIGH - 30.
MODIFY S_DATE.
ENDLOOP.

Nag

Read only

Former Member
0 Likes
3,129

Try this code,

DATA: w_duration type PSEN_DURATION.

IF w_duration IS INITIAL.

w_duration-durmm = 1.

ENDIF.

CALL FUNCTION 'HR_PSF_FP1_ADDSUB_DURATION_DAT'

EXPORTING

id_date = w_start_dt u201Cdate_low1 and date_high1

is_duree = w_duration

id_crule = '0100'

id_opera = '-' u201C u2018-u2018 operator since you want the date one month less

IMPORTING

ed_date = w_end_dt u201C output date

EXCEPTIONS

error_calculation = 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.

  • ELSE.

  • w_end_dt = w_end_dt - 1.

ENDIF.

u2018w_end_dtu2019 will be the end date of the Function Module.

Adjust the date one less or one more according to your need.

w_end_dt = w_end_dt - 1.

OR

w_end_dt = w_end_dt + 1.

Hope this helps you,

Regards,

Abhijit G. Borkar

Read only

former_member227140
Active Participant
0 Likes
3,129

question answered with help from experts