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 format

Former Member
0 Likes
554

Hi everybody...

In my input file ,DATE field having 3 different formats

that are <b>dd/mm/yyyy</b> , <b>dd.mm.yyyy </b> and

<b>dd-mm-yyyy.</b>

my doubt is ,how to convert above mentioned date formats into <b>yyyymmdd</b> format .

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
533

use the Function module

CONVERT_DATE_TO_INTERNAL

to convert dd/mm/yyyy to yyyymmdd.

regards

vijay

4 REPLIES 4
Read only

Former Member
0 Likes
534

use the Function module

CONVERT_DATE_TO_INTERNAL

to convert dd/mm/yyyy to yyyymmdd.

regards

vijay

Read only

Former Member
0 Likes
533

replace '.' with '/' dd.mm.yyyy

replace '-' with '/' dd-mm-yyyy

REPLACE ALL OCCURRENCES OF '.' IN date WITH '/'. 
REPLACE ALL OCCURRENCES OF '-' IN date WITH '/'.

and use this fm <b>CONVERT_DATE_TO_INTERNAL</b>

make sure you should move the date to char 10 and do replace...

regards

vijay

Read only

Former Member
0 Likes
533

Hi

In all formats you have the date is always:

DDsMMsYYYY

where s is a separatore and it can be /,. or -, but this isn't important for you, because where the numbes (days, month and year) of day should be important.

The first second positions are always the day, fourth and fifth positions are the month and the last four positions are the year.

So you can always to do:

DATA: DAY_OUT LIKE SY-DATUM.

WRITE: DAY_IN+6(4) TO DAY_OUT(4),

DAY_IN3(2) TO DAY_OUT4(2),

DAY_IN(2) TO DAY_OUT+6(2).

or also:

CONCATENATE DAY_IN6(4)DAY_IN3(2)DAY_IN(2)INTO DAY_OUT.

Max

Read only

Former Member
0 Likes
533

If it is always in <b>DD</b>x<b>MM</b>x<b>YYYY</b> format then you can simply do:

<b>concatenate input_date+6(4) input_date+3(2) input_date(2) into output_date.</b>