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: 

Julian date

Former Member
0 Kudos
1,239

Hi,

Does anyone know if there's a function module that converts a current date to a julian date?

Thanks!

Rob

1 ACCEPTED SOLUTION

suresh_datti
Active Contributor
0 Kudos
280

Hi Robby,

I dont think there is a function module that does the conversion.. but you can use the following piece of code..


data: W_JULIAN_DATE(6).
PERFORM CONVERT_DATE_TO_YYDDD(RFFOGB_T) USING
              SY-DATUM W_JULIAN_DATE.

write:/  W_JULIAN_DATE.

Regards,

Suresh Datti

4 REPLIES 4

suresh_datti
Active Contributor
0 Kudos
281

Hi Robby,

I dont think there is a function module that does the conversion.. but you can use the following piece of code..


data: W_JULIAN_DATE(6).
PERFORM CONVERT_DATE_TO_YYDDD(RFFOGB_T) USING
              SY-DATUM W_JULIAN_DATE.

write:/  W_JULIAN_DATE.

Regards,

Suresh Datti

0 Kudos
280

Robby,

It is not a func mod... but it is pretty straight forward.

data: julian_day(3) type n,

date_aux type d,

date_I_need type d.

  • first day of the year

concatenate date_I_need(4) '0101' into date_aux.

julian_day = date_I_need - date_aux.

julian_day = julian_day + 1.

0 Kudos
280

Thank you, John! Your reply solved the problem 🐵

0 Kudos
280

I know that you problem is already solved, but I had this code sample that I thought I might share. It uses a local class.




report zrich_0002 .

***********************************************************************
*       CLASS lcl_julian_day DEFINITION
***********************************************************************
class lcl_julian_day definition.

  public section.

    types: t_juld(3) type n.

    class-data:
            julian_day type t_juld,
            date type sy-datum.

    class-methods:

            get_julian_day importing im_date type sy-datum.

endclass.

parameters: p_date type sy-datum.

start-of-selection.

  call method lcl_julian_day=>get_julian_day( p_date ).

  write:/ lcl_julian_day=>date,
          lcl_julian_day=>julian_day.

***********************************************************************
*       CLASS lcl_julian_day IMPLEMENTATION
***********************************************************************
class lcl_julian_day implementation.

  method get_julian_day.

    date = im_date.

    data: firstofyear type sy-datum value 'XXXX0101'.

    replace 'XXXX' with date+0(4) into firstofyear.
    julian_day = ( date - firstofyear ) + 1.

  endmethod.

endclass.


Regards,

Rich Heilman