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

Julian date

Former Member
0 Likes
2,876

Hi,

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

Thanks!

Rob

1 ACCEPTED SOLUTION
Read only

suresh_datti
Active Contributor
0 Likes
1,917

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

Hi,

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

Thanks!

Rob

4 REPLIES 4
Read only

suresh_datti
Active Contributor
0 Likes
1,918

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

Read only

0 Likes
1,917

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.

Read only

0 Likes
1,917

Thank you, John! Your reply solved the problem 🐵

Read only

0 Likes
1,917

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