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

time conversion

Former Member
0 Likes
491

Hey everybody!

I´m writing my diploma thesis in the field of BW and I have to do a little time conversion.

I hav a date like "22.01.1980" in my source and two destination fields CALYEAR (YYYY) and CALMONTH (MM/YYYY like 01/1980).

What is the easiest way to convert the date with ABAP or is there a predefined function?

Thanks in advance!

Philipp

2 REPLIES 2
Read only

Former Member
0 Likes
422

Hi,

REPORT ychatest.

DATA: int_datum LIKE sy-datum VALUE '20070705',

ext_datum(11) TYPE c.

CALL FUNCTION 'CONVERSION_EXIT_SDATE_OUTPUT'

EXPORTING

input = int_datum

IMPORTING

output = ext_datum.

TRANSLATE ext_datum USING '.-'.

WRITE : ext_datum.

Regards,

Omkar.

Read only

Former Member
0 Likes
422

Seems your requirement is you have input date in format "22.01.1980".

you need output as CALYEAR (YYYY) and CALMONTH (MM/YYYY like 01/1980).

Solution:

1. Call function module CONVERSION_EXIT_SDATE_INPUT, giving the input date in '22.01.1980' (current user format).

2. The function module will return the date in sy-datum format. ie, YYYYMMDD.

3. CALYEAR = returndate+0(4).

4. CALMONTH = returndate4(2) '/' returndate6(2).