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

Former Member
0 Likes
1,204

Hi,

I have an input file in which I get the date as 'mm/d/yyyy' eg: 12/31/9999

Now I need to process records from this file in SAP wrt the date.

Can anyone kindly advice how do I convert 'mm/dd/yyyy' to 'yyyymmdd' - sy-datum format?

Kindly treat this as an urgent requirement.

Thanks.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
917

Hi Anand,

Date/Month Related Function Modules:

DATE_CONV_EXT_TO_INT - user formatted date is converted to system date

RP_CALC_DATE_IN_INTERNAL – add/subtract year/month/days from a date

reward pts if found usefull:)

Regards

Sathish

6 REPLIES 6
Read only

Former Member
0 Likes
917

Hi,

Use FM CONVERSION_EXIT_IDATE_INPUT or CONVERT_DATE_TO_INTERNAL for ur requirement.

Regards,

Himanshu

Read only

Former Member
0 Likes
918

Hi Anand,

Date/Month Related Function Modules:

DATE_CONV_EXT_TO_INT - user formatted date is converted to system date

RP_CALC_DATE_IN_INTERNAL – add/subtract year/month/days from a date

reward pts if found usefull:)

Regards

Sathish

Read only

Former Member
0 Likes
917

Hi

You can offset the entered data field into day,month and year separately like

your entered data is MMDDYYYY

month = date+0(2)

day = date+2(2)

year = date+4(4).

Now concatenate year month day into date1.

display the date1 in th report

<b>Reward points for useful Answers</b>

Regards

Anji

Read only

Former Member
0 Likes
917

Hi,

Chk this.

data : out_date(10) like char,

in_date(10) like char.

in_date = '10.02.2007'.

*take variables V1, V2, V3.

V1 = in_date+ 0(4).

V2 = in_date+ 5(2).

V3 = in_date+ 7(2).

Concatenate V1 V2 V3 into date separated by '/'.

Now, out_date will have DD/MM/YYYY

Otherwise,Use FM <b>CONVERSION_EXIT_PDATE_OUTPUT</b>

Regards,

Padmam.

Read only

sharadendu_agrawal
Active Participant
0 Likes
917

In this code you can interchange the location of the year,day and month fields as required.

DATA: date LIKE sy-datum,

changedate(10) TYPE c.

DATA: BEGIN OF it_date1, " To accept date into a internal table

yyyy(4),

mm(2),

dd(2),

END OF it_date1.

DATA: BEGIN OF it_date2, " Internal table for dd/mm/yyyy format

dd(2),

mm(2),

yyyy(4),

END OF it_date2.

DATA: BEGIN OF it_date3, " Internal table for mm/dd/yyyy format

mm(2),

dd(2),

yyyy(4),

END OF it_date3.

date = sy-datum.

it_date1 = date.

MOVE-CORRESPONDING it_date1 TO: it_date2,it_date3.

WRITE it_date2 TO changedate USING EDIT MASK '__/__/____'. " dd/mm/yyyy

WRITE:/ 'Date in dd/mm/yyyy format',

/ changedate.

SKIP.

CLEAR changedate.

WRITE it_date3 TO changedate USING EDIT MASK '__/__/____'. " mm/dd/yyyy

WRITE:/ 'Date in mm/dd/yyyy format',

/ changedate.

Reward if helpful.

Cheers,

Sharadendu

Read only

Former Member
0 Likes
917

DATA t_date TYPE FIST-SEARCHW.

move date to t_date.

CALL FUNCTION 'SF_SPECIALCHAR_DELETE'

EXPORTING

WITH_SPECIALCHAR = T_DATE

IMPORTING

WITHOUT_SPECIALCHAR = T_DATE

EXCEPTIONS

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

*now t_date will have '12319999'

concatenate t_date+4(4) t_date(4) into t_date.

move t_date to date.

*now date will have '99991231'.