Skip to Content
avatar image
-1
Former Member

how do I convert julian to gregorian date in abap example code?

Need some assistance

Add comment
10|10000 characters needed characters exceeded

  • Rather curious about the story behind this question... Are there businesses using Julian calendar? Some Orthodox Church runs SAP? Need to run the financial reports for the 15th century? Some ABAP trainer is pulling your leg?

    Scratching my head here why would this be possibly needed...

  • Former Member

    It's not for any business purpose. I was just attempting too write some practice code that converts Julian calendar date to the Gregorian calendar. I'm a junior developer and trying work on my skills.

  • IMHO you need better examples to polish your skills. There is no point choosing a conversion that makes no sense (as Sandra also pointed out). Now converting, say, a calendar date into a fiscal period - that's something you are likely to actually use in real life.

    Why not just search for the date conversion questions on SCN and then attempt solutions? Although realy, date conversion is usually a simple FM or method call, so hardly any skill is needed for that (IMHO, again).

    Good luck.

  • Get RSS Feed

3 Answers

  • Mar 29, 2017 at 08:38 PM

    ABAP counts days from 00010101. The switch from Julian to the Gregorian calendar is handled in the conversion rules from numeric to date and vice versa as follows:

    • Converting 577,736 to a target field of type d produces 4.10.1582, and converting 577,737 produces 15.10.1582. The dates for the intermediate days that were lost during the switch from the Julian to the Gregorian calendar cannot be produced by assigning a numeric value to a target field of type d.
    • The conversion of a date into the number of days since 01.01.001 is designed in such a way that the transition from the Julian to Gregorian calendar is respected: 4.10.1582 produces the number 577,736 and 15.10.1582 produces 577,737. Converting the dates of the nonexistent days between 5.10.1582 and 14.10.1582 produces the same result as converting the existing days from 15.10.1582 to 24.10.1582.

    So ABAP does it itself. What should a conversion between Julian and Gregorian calendar be about? If you want to calculate anything, the above rules should be sufficient.

    Add comment
    10|10000 characters needed characters exceeded

  • Mar 30, 2017 at 05:19 AM

    I fully agree with Horst answer. But just to say about the nature of the question: converting a date from Julian calendar to Gregorian is mostly non-sense: the Gregorian calendar has replaced the Julian calendar, officially from October 5th 1582, as Horst says (in many countries, and adopted by others later).

    If your question is more about "if the Julian calendar had continued in some countries after 4.10.1582, how could we translate a Julian date after 4.10.1582 into Gregorian calendar?" then:

    • (Fictious) Julian 5.10.1582 would be Gregorian 15.10.1582 (+10 days)
    • It's >= 10 days for all next days, as leap years exist every 100 years (except every 400 years) in Julian calendar; Jul 20.03.2017 would be Greg 02.04.2017 i.e. +13 days)
    • Etc.
    • the ABAP date calculations are explained by Horst above
    Add comment
    10|10000 characters needed characters exceeded

  • Apr 01, 2017 at 09:40 AM

    Say, is the question about Julian Day and not about Julian Calendar? That at least would make some sense.

    According to http://quasar.as.utexas.edu/BillInfo/JulianDatesG.html the astronomer´s julian day was even invented by a different Julius (not good ol´ Gaius Julius Cesar).

    Googling the web you find some pages that present formulas and code snippets that show how to convert between Gregorian Dates and Julian Days.

    All you have to do is to write some basic ABAP that implements these formulas.

    Add comment
    10|10000 characters needed characters exceeded