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 YYYYDDD to YYYYMMDD

Former Member
0 Likes
2,564

Hello,

my source machine provides dates in the format YYYYDDD (i.e. 2007091 = April 01.2007).

I need the format YYYYMMDD = 20070401.

Any Ideas in ABAB or BW-Converting routines ?

Thanks

Armin Batzelt

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,122

hi armin,

try this one

DATA: w_date_original(7) TYPE c VALUE '2007091',
      w_date      TYPE sy-datum,
      w_date1     TYPE sy-datum.
CONCATENATE  w_date_original(4)  '0101' INTO w_date .
w_date =   w_date + w_date_original+4(3) - 1 .

WRITE:/ w_date.
CALL FUNCTION 'CONVERSION_EXIT_PDATE_OUTPUT'
  EXPORTING
    input         = w_date
 IMPORTING
   OUTPUT        = w_date1

.

regards,

sandeep

Hello,

my source machine provides dates in the format YYYYDDD (i.e. 2007091 = April 01.2007).

I need the format YYYYMMDD = 20070401.

Any Ideas in ABAB or BW-Converting routines ?

Thanks

Armin Batzelt

12 REPLIES 12
Read only

Former Member
0 Likes
2,122

Hi,

Use function module

CONVERSION_EXIT_SDATE_INPUT

You will get the required date format

Best regards,

Brijesh

Read only

0 Likes
2,122

Hi Brijesh,

thanks for your fast answer.

the function module CONVERSION_EXIT_SDATE_INPUT accepts dates in format 01.APR.2007, but not in my format (2007091).

Armin

Read only

0 Likes
2,122

Hi Armin,

Is the date format for your input is 'YYYYMMDD' ?

Cause above you have mentioned 2007091

Is it 20070401

Best Regards,

Brijesh

Read only

0 Likes
2,122

Hi Brijesh,

I have 2007091 and I need 20070401.

091 is the 91th day in 2007.

Armin

Read only

0 Likes
2,122

Hi

I can give you an idea first you find the first day of the year and the by using OFFSET u read 091 and by adding this 91 to the first day of the year you will get the result.

use this FM to get the first day and last day of the month

HR_BEN_SPENDA_FIRST_LAST_DAY

Regards

pavan

Read only

0 Likes
2,122

Hi pavan,

this sounds good.

i think the first day of 2007091 will be 20070101 (1. Jan).

How do I add a number of days to a date ?

Thanks

Armin

Read only

Former Member
0 Likes
2,122

hi,

Check out the below related thread

Regards.

Santosh

Read only

0 Likes
2,122

Hi santosh,

this thread is not exactly about my problem, it is another format.

Thanks Armin

Read only

JozsefSzikszai
Active Contributor
0 Likes
2,122

hi Armin,

I would suggest some manual calculation:

DATA : lv_source(7) TYPE n,
            lv_target TYPE sy-datum.

CONCATENATE lv_source(4) '0101' INTO lv_target.
lv_target = lv_target +lv_source+4(3) - 1.

hope this helps

ec

Read only

Former Member
0 Likes
2,122

Hello Armin,

You can try this way.

Your format is YYYYDDD. Take the last date digits in it into a variable Here 'num'.

data: num type i .
data: date type sy-datum,
date+0(4) = sy-datum+0(4).
date+4(2) = '01'.
date+6(2) = '01'.
date = date + num.
write date.

Hope this would solve your purpose

Regards

Indu.

Read only

Former Member
0 Likes
2,123

hi armin,

try this one

DATA: w_date_original(7) TYPE c VALUE '2007091',
      w_date      TYPE sy-datum,
      w_date1     TYPE sy-datum.
CONCATENATE  w_date_original(4)  '0101' INTO w_date .
w_date =   w_date + w_date_original+4(3) - 1 .

WRITE:/ w_date.
CALL FUNCTION 'CONVERSION_EXIT_PDATE_OUTPUT'
  EXPORTING
    input         = w_date
 IMPORTING
   OUTPUT        = w_date1

.

regards,

sandeep

Read only

Former Member
0 Likes
2,122

Hi,

execute this fm OIUH_PWFROMJULIANDT

Function module OIUH_PWFROMJULIANDT

Changing parameters Value

DATE 2007091

RDATE YYYYMMDD

RCODE

Result: 2007-04-01

<just play around with this fm .

br<vijay