Julian Date Number/Gregorian Calendar Date Conversions

01142019, 01:21 AM
(This post was last modified: 01162019 02:41 PM by Eddie W. Shore.)
Post: #1




Julian Date Number/Gregorian Calendar Date Conversions
HP Prime Program JD: Gregorian Date to Julian Date Number
Arguments: four digit year, month, day JD(y,m,d) Code:
HP Prime Program GREG: Julian Date Number to Gregorian Date Argument: Julian Date Number GREG(j) Code: EXPORT GREG(j) Examples Gregorian Date: 1988, October 31 JD: 2447466 Gregorian Date: 1999, January 11 JD: 2451190 Gregorian Date: 2017, March 21 JD: 2457834 Source: "Julian Day" Wikipedia. Edited (when retrieved) November 19, 2018. Retrieved January 11, 2019. https://en.wikipedia.org/wiki/Julian_day Blog post link: https://edspi31415.blogspot.com/2019/01/...cg50.html 

01142019, 12:01 PM
(This post was last modified: 01142019 01:16 PM by Dieter.)
Post: #2




RE: Julian Date Number/Gregorian Calendar Date Conversions
(01142019 01:21 AM)Eddie W. Shore Wrote: HP Prime Program JD: Gregorian Date to Julian Date Number Eddie, there is no need to calculate this manually with lots of formulas. You can do this with the Prime's builtin calendar functions: For the Julian day number simply determine the date difference to 15821015 and add 2299161. For the Gregorian date subtract 2299161 from the Julian day number and add this number of days to 15821015. You will know the correct Prime syntax for this. ;) Edit: I have just posted a short 12C program using this approach in the General Software Library. In both cases the date may not be earlier than Oct 15, 1982. This is the first day of the Gregorian calendar, earlier Gregorian dates simply do not exist. If you run your program with an earlier date the result will be invalid – the program works as if the Gregorian calendar existed before the mentioned date (proleptic calendar). I don't know how the Prime behaves in this regard. Does it return an error for earlier dates? (01142019 01:21 AM)Eddie W. Shore Wrote: Examples Sorry, that's wrong. The JDN for this date is 2451118. 2447466 is the JDN of 31 Oct 1988. Dieter 

01142019, 11:13 PM
Post: #3




RE: Julian Date Number/Gregorian Calendar Date Conversions
(01142019 12:01 PM)Dieter Wrote: I don't know how the Prime behaves in this regard. Does it return an error for earlier dates? Yes. It says "Error: Invalid input" for date inputs (or results) outside the range [1582.1015, 9999.1231]. X<> c Joe 

01162019, 02:48 PM
(This post was last modified: 01162019 02:53 PM by Eddie W. Shore.)
Post: #4




RE: Julian Date Number/Gregorian Calendar Date Conversions
Dieter,
I meant 1988, not 1998. Typo on my end. The post was on my blog (see the link in the original post) is for three calculators, not just for the HP Prime. I wanted to get an algorithm down to include code for any calculators that don't have the wonderful DDAYS and DATEADD/DATE+ functions that HP Prime, and most highend HP calculators have. Quite frankly, the DDAYS and DATEADD should be on every calculator. In future programs, especially on the HP Prime, I will use these functions. The DDAYS function is one of my most used and favorite functions! 

01162019, 08:18 PM
Post: #5




RE: Julian Date Number/Gregorian Calendar Date Conversions
(01162019 02:48 PM)Eddie W. Shore Wrote: Quite frankly, the DDAYS and DATEADD should be on every calculator. In future programs, especially on the HP Prime, I will use these functions. Interesting that the Prime manual refers only to DateDays (the Finance app function), and DELTADAYS (Catalog) and not DDAYS. Looks like the latter was renamed but the change didn't make the manual? Cambridge, UK DM16, DM42, 30b (WP 34S), 50g, 50g (newRPL), Prime G2 various Casio, Rockwell 18R :) 

« Next Oldest  Next Newest »

User(s) browsing this thread: 1 Guest(s)