cancel
Showing results for 
Search instead for 
Did you mean: 

Julian Date Conversion

Former Member
0 Kudos

Hello,

Is there a function to convert date in the YYDDD format to YYYYMMDD ?

Thanks.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi

check the fun modules

CONVERT_DATE_TO_INTERN_FORMAT

CONVERT_DATE_TO_EXTERNAL

CONVERT_DATE_TO_INTERNAL

CONVERT_DATE_INPUT

CONVERT_DATE_BY_PERIOD_INPUT

CONVERT_DATE_BY_PERIOD_OUTPUT

Regards

Anji

Answers (5)

Answers (5)

Former Member
0 Kudos

Hi Stephen,

I don't think there is a generic SAP function to do this. You will have to write the code yourself.

Sorry......

Former Member
0 Kudos

Cheers

Former Member
0 Kudos

Thanks for the help guys.

Former Member
0 Kudos

Hi

U can use something like this:

DATA: FIRST_DAY TYPE SY-DATUM,
           MY_DAY    TYPE SY-DATUM.

DATA JULIAN_DATE(5) TYPE N VALUE '07256'.

* Calculate first day:

FIRST_DAY(2)   = '20'.
FIRST_DAY+2(2) = JULIAN_DATE(2).
FIRST_DAY+4(4) = '0101'.

MY_DAY = FIRST_DAY + JULIAN_DATE+2(3) - 1.

WRITE MY_DAY.

Max

naimesh_patel
Active Contributor
0 Kudos

I haven't find any FM to convert this.

But I have tried to code it ... please look at the code you will have better idea.

REPORT  ZTEST_NP.

PARAMETERS: P_JDATE(5) TYPE N DEFAULT '07030'.

DATA: P_DATE TYPE D,
      L_YEAR TYPE N,
      L_DATE TYPE D.

START-OF-SELECTION.
  P_DATE+0(2) = '20'.
  L_YEAR = P_JDATE+0(2) - 1.
  P_DATE+2(2) = L_YEAR.
  P_DATE+4(4) = '0000'.

  L_DATE = P_DATE.
  L_DATE+4(4) = '1231'.

  P_DATE = L_DATE + P_JDATE+2(3).

  WRITE: P_JDATE,
        / P_DATE.         "<< P_date will be 20070130

Regards,

Naimesh Patel

former_member194669
Active Contributor
0 Kudos

Hi,

Check the standard program RFFORIG4 and form name CONVERT_DATE_TO_YYDDD


*----------------------------------------------------------------------*
* FORM CONVERT_DATE_TO_YYDDD                                           *
*----------------------------------------------------------------------*
* Convert Type D Dates to _YYDDD Format                                *
*----------------------------------------------------------------------*
form convert_date_to_yyddd using upgb_dattyped upgb_datyyddd.
data: upgb_d08dataa     type d,
        upgb_n03dataa(3)  type n.

  move:  upgb_dattyped  to upgb_d08dataa,
         '0101'         to upgb_d08dataa+4(4).
  upgb_n03dataa = 1 + upgb_dattyped - upgb_d08dataa.
  write: space               to upgb_datyyddd+0(1),
         upgb_d08dataa+2(2)  to upgb_datyyddd+1(2),
         upgb_n03dataa       to upgb_datyyddd+3(3).
* Check if the day is 1231:
if sy-datum+4 = '1231'.
      write sy-datum+2(2) to upgb_datyyddd+1(2).
      write '001' to upgb_datyyddd+3(3).
  endif.


endform.                               "CONVERT_DATE_TO_YYDDD