Application Development 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: 

Date Conversion YYYYDDD to YYYYMMDD

Former Member
0 Kudos

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

Former Member
0 Kudos

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

12 REPLIES 12

Former Member
0 Kudos

Hi,

Use function module

CONVERSION_EXIT_SDATE_INPUT

You will get the required date format

Best regards,

Brijesh

0 Kudos

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

0 Kudos

Hi Armin,

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

Cause above you have mentioned 2007091

Is it 20070401

Best Regards,

Brijesh

0 Kudos

Hi Brijesh,

I have 2007091 and I need 20070401.

091 is the 91th day in 2007.

Armin

0 Kudos

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

0 Kudos

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

Former Member
0 Kudos

hi,

Check out the below related thread

Regards.

Santosh

0 Kudos

Hi santosh,

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

Thanks Armin

JozsefSzikszai
Active Contributor
0 Kudos

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

Former Member
0 Kudos

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.

Former Member
0 Kudos

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

Former Member
0 Kudos

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