<p>Like @James K said, the MJD is simply a count, so you can set some arbitrary date to be <code>0</code> and go from there. </p>

<p>For example, take today's MJD date and say there was one event today:</p>

<pre><code>Today = 57657 
</code></pre>

<p>Add three months and 12 days to the next event:</p>

<pre><code>Today + 103 = 57760
</code></pre>

<p>So if you called ten days before the first event <code>0</code>, then the "dates" of the first two events would simply be the following:</p>

<pre><code>Start = Event_1 - 10 = 0 
Event_1 = Start + 10 = 10 &lt;-- Semantics right!
Event_2 = Event_1 + 103 = 113
</code></pre>

<p>It really is that simple. Just set a variable to equal whatever starting MJD you want to be zero and count earth days between events. </p>

CC BY-SA 3.0
2016-09-25T18:52:24.973Z
2016-09-25T18:57:40.540Z
2016-09-25T18:57:40.540Z
LaserYeti
<p>Hopefully I'm in the appropriate section as my question is mainly about coding, but it's for astronomy. </p>

<p>Right now I'm trying to figure out how I can take a range of MJD values and convert them into number of days elapsed so I can normalize a plot of two supernova and their absolute magnitudes over time in IDL. Is there a simple conversion for this I'm not seeing or do I need to tediously convert every value to determine the number of days to use for my x-axis?</p>

<p>Note: I do not wish to convert to the date, but the actually number of days elapsed as to normalize my two plots for comparison.</p>

<p>Thanks!</p>

CC BY-SA 3.0
2016-09-25T18:16:55.020Z
Since MJD is a simple number of days, can't you just do `days_elapsed = mjd2 - mjd1` (or whatever the syntax is for idl). This might be a better fit for StackOverflow.
James K
<supernova>
Convert MJD date range to number of days elapsed in IDL
cdav1601
# Convert MJD date range to number of days elapsed in IDL

(Asked by: username_0 on 2016-09-25)

Hopefully I'm in the appropriate section as my question is mainly about coding, but it's for astronomy.

Right now I'm trying to figure out how I can take a range of MJD values and convert them into number of days elapsed so I can normalize a plot of two supernova and their absolute magnitudes over time in IDL. Is there a simple conversion for this I'm not seeing or do I need to tediously convert every value to determine the number of days to use for my x-axis?

Note: I do not wish to convert to the date, but the actually number of days elapsed as to normalize my two plots for comparison.

Thanks!

**Tags:** supernova
> **Comments:**
> **username_1**: Since MJD is a simple number of days, can't you just do `days_elapsed = mjd2 - mjd1` (or whatever the syntax is for idl). This might be a better fit for StackOverflow.  

---

## 1 answers

### Answer by username_2 on 2016-09-25. Score: 2

Like @James K said, the MJD is simply a count, so you can set some arbitrary date to be 0 and go from there. 
For example, take today's MJD date and say there was one event today:
Today = 57657 

Add three months and 12 days to the next event:
Today + 103 = 57760

So if you called ten days before the first event 0, then the "dates" of the first two events would simply be the following:
Start = Event_1 - 10 = 0 
Event_1 = Start + 10 = 10 <-- Semantics right!
Event_2 = Event_1 + 103 = 113

It really is that simple. Just set a variable to equal whatever starting MJD you want to be zero and count earth days between events.


---

