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: 

Date format

Former Member
0 Kudos

hi,

my requirement is i have month and year which i am getiing in select option from the user

in the format eg: '11.2007' and '06.2007' (he enters in the screen) i have to find the months

between and do some calculation.

i have the function module for it HR_HK_DIFF_BT_2_DATES .my problem is i concatenated and passed two days in the format like '20071101' and '20070630' but its not showing the month between .is that the format i give is wrong...plz help me

regards,

karthik.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Here is the code:

report ztesttej13.

parameters: p_date(10),

p_date1(10).

data: v_date like p0001-begda,

v_date1 like p0001-endda,

v_months like P0347-SCRMM.

v_date = p_date.

v_date1 = p_date1.

CALL FUNCTION 'HR_HK_DIFF_BT_2_DATES'

EXPORTING

DATE1 = v_date

DATE2 = v_date1

OUTPUT_FORMAT = '08'

IMPORTING

  • YEARS =

MONTHS = v_months

  • DAYS =

EXCEPTIONS

INVALID_DATES_SPECIFIED = 1

OTHERS = 2

.

IF SY-SUBRC <> 0.

ENDIF.

write: v_months.

And I am passing 20071101 to P_date and 20070601 to p_date1.

I am thinking the way you defined your date parameters may be wrong.

8 REPLIES 8

Former Member
0 Kudos

Hi.. Looks like you are passing an incorrect Output Format.. If you pass 08.. it gives you the months between..

0 Kudos

thx,

but i tried that too i am pasting my code here

CALL FUNCTION 'HR_HK_DIFF_BT_2_DATES'

EXPORTING

DATE1 = t_dates-high <----


20071101

DATE2 = t_dates-low <----


20070630

OUTPUT_FORMAT = '08'

IMPORTING

  • YEARS =

MONTHS = w_months

  • 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.

i think this could help to sort it out

Former Member
0 Kudos

You can use the FM MONTHS_BETWEEN_TWO_DATES_NEW.

Albert

Former Member
0 Kudos

The date format is wrong:

It should be 11/01/2007 and 06/30/2007

0 Kudos

but i dont get the date from user i am just getting as 11.2007(Month.Year) i am concatenating and putting the value there in that format is that i can give as you said 11/01/2007 but again date is length of 8.what could be the format i can specify there??

your help will be appreciated

0 Kudos

You have to pass a date like:

data: l_st_date like sy-datum,

l_end_Date like sy-datum.

data: l_your_date(7) type c value '11.2007'.

l_st_date0(4) = l_your_date3(4).

l_st_date4(2) = l_your_date0(2).

l_st_date+6(2) = '01'.

l_end_date0(4) = l_your_date3(4).

l_end_date4(2) = l_your_date0(2).

l_end_date+6(2) = '31'.

Former Member
0 Kudos

Here is the code:

report ztesttej13.

parameters: p_date(10),

p_date1(10).

data: v_date like p0001-begda,

v_date1 like p0001-endda,

v_months like P0347-SCRMM.

v_date = p_date.

v_date1 = p_date1.

CALL FUNCTION 'HR_HK_DIFF_BT_2_DATES'

EXPORTING

DATE1 = v_date

DATE2 = v_date1

OUTPUT_FORMAT = '08'

IMPORTING

  • YEARS =

MONTHS = v_months

  • DAYS =

EXCEPTIONS

INVALID_DATES_SPECIFIED = 1

OTHERS = 2

.

IF SY-SUBRC <> 0.

ENDIF.

write: v_months.

And I am passing 20071101 to P_date and 20070601 to p_date1.

I am thinking the way you defined your date parameters may be wrong.

0 Kudos

thx mate my problem solved.....thx for your help