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

Regardging date conversion

Former Member
0 Likes
439

I have date coming up of form "04/25/06" which I want to convert into sy-datum (20060425) format. Can you guys help me how?

Thanks in advance.

1 ACCEPTED SOLUTION
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
413

You can use the CONVERT_DATE_TO_INTERNAL function module.



report zrich_0001.


data: date(10) type c value '06/15/06'.
data: the_date type sy-datum.

call function 'CONVERT_DATE_TO_INTERNAL'
     exporting
          date_external = date
     importing
          date_internal = the_date.


write:/ the_date.

Regards,

Rich Heilman

3 REPLIES 3
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
414

You can use the CONVERT_DATE_TO_INTERNAL function module.



report zrich_0001.


data: date(10) type c value '06/15/06'.
data: the_date type sy-datum.

call function 'CONVERT_DATE_TO_INTERNAL'
     exporting
          date_external = date
     importing
          date_internal = the_date.


write:/ the_date.

Regards,

Rich Heilman

Read only

0 Likes
413

hi Nuren,

Use FM <b>CONVERT_DATE_TO_INTERNAL</b>

CALL FUNCTION <b>'CONVERT_DATE_TO_INTERNAL'</b>

EXPORTING

date_external = input

IMPORTING

date_internal = output

EXCEPTIONS

date_external_is_invalid = 1

OTHERS = 2.

IF sy-subrc <> 0.

MESSAGE e888(fk) RAISING wrong_input.

ENDIF.

Read only

Former Member
0 Likes
413

DATA: v_year(4) TYPE n.

MOVE my_input_date+6(2) TO v_year.
IF v_year > sy-datum+2(2). <-- assuming the input date will not be in future
  v_year = v_year + 1900.
ELSE.
  v_year = v_year + 2000.
ENDIF.
CONCATENATE v_year
            my_input_date+0(2)
            my_input_date+3(2)
       INTO my_target_date.