Reputation: 3
I am looking for a formula where I can put a 5 digit Modified Julian Date and have it convert it to today's date for me.
I did it in a way where I have a separate sheet with a table but although it works, I am looking for a way without the need of a separate table. Here is some information:
00000 should translate to 1858-11-17
58890 should translate to 2020-02-11
Every time the number goes up 1, it should go up 1 day. This needs to have leap years in consideration as well. Any help will be appreciated.
Here is a website that currently does the conversions:
http://www.csgnetwork.com/julianmodifdateconv.html
This has to be done without macros, literally need it in formula format.
Upvotes: 0
Views: 2107
Reputation: 1
Yes or no…
It was in the Middle Ages that the French Joseph Juste Scaliger (1540-1609), proposed in 1583 in his treatise on chronology “Opus novum de emendatione temporum”, a calendar based on the counting of days called “Julian days". He proposed to set as the origin of his calendar January 1 ~4713 at noon. (~ means that we do not take into account year 0. ~4713 = -4712 BC)
For convenience, since 1973, we have used November 17, 1858 at 0 a.m. as the origin of the Julian calendar, which we will call “Modified Julien Date”. The MJD was chosen by subtracting 2400000.5 from January 1 -4712 in order to use smaller numbers and above all bring the time back to 0h instead of noon (0.5 day). Today the MJD is given with 5 digits.
Today for simplification, it was agreed that:
UNIX:
for example : for ntp, in loopstats file, first field is MJD to read this file : awk '{ printf "%s -- %s\n", strftime("%c", ($1-40587)*86400 + $2), $0 }' /var/log/ntpsec/loopstats
Excel:
just type the formula in a cell and apply the date format to this cell: =A1-15018
For summarize:
For Unix/Debian:
In /var/log/ntpsec/loopstats file, first field ($1) = MJD on 5 numbers, second field ($2) = time
awk '{ printf "%s -- %s\n", strftime("%d/%m/%y %H:%M:%S", ($1-40587)*86400 + $2), $0 }' /var/log/ntpsec/loopstats
For Excel:
H5 = MJD on 5 digits and I5 = time
Date = H5-15018 (and apply a date format to the cell)
Time = I5/86400 (and apply a time format to the cell)
So, conclusion:
MJD = 58890 => February 11, 2020 it’s ok for me.
But as I wrote above, Excel only knows the dates from January 1, 1900. As proof, define the date format of a cell with the format dddd mmmm yyyy then indicate in this cell 01/01/1900, Excel will display Sunday, January 1, 1900. But if you indicate in this same cell 31/12/1900 Excel will indicate 31/12/1900 without indicating the name of the day, proof that is not able to calculate that. (I'm French, the date for me is day/month/year, but that doesn't change the problem)
Yes MJD = 00000 => November 17, 1858 but Excel cannot calculate it with basic functions. If you want to do this, you need to make a program to do that.
Upvotes: -2
Reputation: 60334
Just subtract 15018
and format the result as a date.
Why 15018
and not 15020
?
1-Jan-1900
value is 1
15020
= 1-Jan-1900
But, if you had the number 15020
to convert and subtracted 15020
it would --> 0
, not the desired 1
.15020
by 1
to 15019
.Next, there is a deliberate "bug" in Excel, widely discussed both on SO and the internet, whereby the year 1900 is erroneously classified as a leap year.
So for any date equivalent that is after 28-Feb-1900
, we have to subtract an extra 1
.
If you might be dealing with dates between 1/1/1900
and 2/28/1900
you will need to modify the formula to take that into account.
Upvotes: 2