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

Date Conversion - FM ?

Former Member
0 Likes
1,434

Hi everyone,

I want to convert an internal date i.e. 20070924 to SEP2007 (YYYYMMDD) to

MMMDD and was wondering if there is a FM to do this. I have searched

but can't find anything suitable.

I know I could write a bit of code myself to do this but thought a FM would be

better.

thanks

Andy

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,283

you can try this


PARAMETERS : P_DATE LIKE SY-DATUM.
DATA :       res(30).

CALL FUNCTION 'CONVERSION_EXIT_IDATE_OUTPUT'
  EXPORTING
    INPUT         = p_date
 IMPORTING
   OUTPUT        = res
          .
write : / res+2.

regards

shiba dutta

7 REPLIES 7
Read only

Former Member
0 Likes
1,283

HI Scott,

Try this,

DATE_CONV_EXT_TO_INT

Check this sample code,

DATE_CONV_EXT_TO_INT - user formatted date is converted to system date

data: date_intern type d,

date_extern(10).

date_extern = ‘28.03.2000’.

CALL ‘DATE_CONV_EXT_TO_INT’ ID ‘DATINT’ FIELD date_intern ” Intern Date ID ‘DATEXT’ FIELD date_extern. ” Extern Date

Now the field date_intern will have the value ‘20000328’.

Check the sy-subrc for possible wrong input.

CONVERT_DATE_TO_EXTERNAL - Converts date from system storage format to users specified display format

REPORT ZHAR_1 .

data l_date(10).

data l_datum type sy-datum.

l_datum = '20050815'.

CALL FUNCTION 'CONVERT_DATE_TO_EXTERNAL'

EXPORTING

DATE_INTERNAL = l_DATUM

IMPORTING

DATE_EXTERNAL = l_date

EXCEPTIONS

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

write: /1 l_date.

Thanks,

Reward If Helpful.

Read only

Former Member
0 Likes
1,283

HI,

USE FM CONVERSION_EXIT_SDATE_OUTPUT for this format 05DEC2006

OR FM - DATE

Reward points if this helps.

Manish <b></b>

Read only

Former Member
0 Likes
1,283

Use

CONVERT_DATE_TO_INTERN_FORMAT.

Please reward if useful.

Read only

Former Member
0 Likes
1,284

you can try this


PARAMETERS : P_DATE LIKE SY-DATUM.
DATA :       res(30).

CALL FUNCTION 'CONVERSION_EXIT_IDATE_OUTPUT'
  EXPORTING
    INPUT         = p_date
 IMPORTING
   OUTPUT        = res
          .
write : / res+2.

regards

shiba dutta

Read only

0 Likes
1,283

thanks guys for all your replies

Read only

kiran_k8
Active Contributor
0 Likes
1,283

Andy,

These are some date related function modules which I came across.Hope these can give you some lead.

DATE_COMPUTE_DAY - Finds day of the month

DATE_CONV_EXT_TO_INT - user formatted date is converted to system date

DATE_GET_WEEK - convert date into year + week format

DATE_TO_DAY - gives weekday from date

DATE_IN_FUTURE - takes number of days and date - gives future date in user format and system format

MONTH_NAMES_GET - language is only parameter. Returns internal table with months.

MONTH_PLUS_DETERMINE -subtract months from date

WEEK_GET_FIRST_DAY - take input as YYYYWW and it gives first day of the week.

CONVERSION_EXIT_SDATE_OUTPUT-changes the date format as 31 Aug 2007 if given as 31/08/2007.

K.Kiran.

Read only

varma_narayana
Active Contributor
0 Likes
1,283

HI..

This is the Code:

REPORT ZSEL_DATE_CON1.

data: v_date1 type d VALUE '20070110'.

dATA : V_DATE2(6).

CONCATENATE V_DATE1+4(2) V_DATE1(4) INTO V_dATE2.

WRITE: V_dATE2.

<b>REWARD IF hELPFUL.</b>