# Offset when converting excel time to unix time (two whole days)

**URL:** <https://discourse.julialang.org/t/offset-when-converting-excel-time-to-unix-time-two-whole-days/14119>\
**Category:** General Usage\
**Created:** [August 27, 2018, 9:29am UTC](https://discourse.julialang.org/t/offset-when-converting-excel-time-to-unix-time-two-whole-days/14119 "2018-08-27T09:29:44Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![slowbrain](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/slowbrain/32/2224_2.png) [@slowbrain](https://discourse.julialang.org/u/slowbrain)\
**Post date:** [August 27, 2018, 9:29am UTC](https://discourse.julialang.org/t/offset-when-converting-excel-time-to-unix-time-two-whole-days/14119/1 "2018-08-27T09:29:44Z")

</div>

I have data containing excel time stamps (days since 1900-01-01T00:00:00) and trying to convert it to DateTime type. Typically one can google that proper conversion is as follows:

Unix Timestamp = (Excel Timestamp - 25569) \* 86400

Fine, let’s double check that “25569” offset number:

```julia
julia> using Dates

julia> excel_epoch = datetime2unix(DateTime("1900-01-01T00:00:00", "Y-m-dTH:M:S"));
julia> epoch_unix = datetime2unix(DateTime("1970-01-01T00:00:00", "Y-m-dTH:M:S"));

julia> (epoch_unix - epoch_excel)/86400
25567.0

```

What is going on here? If I want to rely purely on Dates package I would get the offset 2 days when converting from excel timestamp to unix timestamp.

---

<div class="post-metadata">

**Author:** ![giordano](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/giordano/32/2166_2.png) [@giordano](https://discourse.julialang.org/u/giordano)\
**Post date:** [August 27, 2018, 9:46am UTC](https://discourse.julialang.org/t/offset-when-converting-excel-time-to-unix-time-two-whole-days/14119/2 "2018-08-27T09:46:07Z")

</div>

Maybe I’m missing something, but between January 1st, 1900 and January 1st, 1970 there are 365 \* 70 + 17 = 25567 days, being 17 the number of leap years (1900 wasn’t a leap year).Where did you find that 25569? Did you check that the conversion with that number is correct?

---

<div class="post-metadata">

**Author:** ![mauro3](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mauro3/32/292_2.png) [@mauro3](https://discourse.julialang.org/u/mauro3)\
**Post date:** [August 27, 2018, 9:52am UTC](https://discourse.julialang.org/t/offset-when-converting-excel-time-to-unix-time-two-whole-days/14119/3 "2018-08-27T09:52:06Z")

</div>

[Wikipedia](https://en.wikipedia.org/wiki/Epoch_(reference_date)) says that the excel epoch is 1900-01-00, which leaves you with one day offset. But the internet indeed suggests 25569, e.g. [here](https://campus.barracuda.com/product/websecuritygateway/knowledgebase/50160000000HmS2AAK/How+can+I+convert+UNIX+timestamps+to+a+human-readable+format+in+Excel+when+exporting+CSV+reports+from+my+Barracuda+Web+Filter/).

---

<div class="post-metadata">

**Author:** ![Sukera](https://avatars.discourse-cdn.com/v4/letter/s/ce7236/32.png) [@Sukera](https://discourse.julialang.org/u/Sukera)\
**Post date:** [August 27, 2018, 9:54am UTC](https://discourse.julialang.org/t/offset-when-converting-excel-time-to-unix-time-two-whole-days/14119/4 "2018-08-27T09:54:04Z")

</div>

> Since 1900 is [incorrectly treated as a leap year](https://en.wikipedia.org/wiki/Leap_year_bug) in these systems, January 0, 1900 actually corresponds to the historical date of December 30, 1899.

Maybe that’s where the second day comes from? Reasons are, as so often, [legacy](https://support.microsoft.com/en-us/help/214326/excel-incorrectly-assumes-that-the-year-1900-is-a-leap-year).

---

<div class="post-metadata">

**Author:** ![giordano](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/giordano/32/2166_2.png) [@giordano](https://discourse.julialang.org/u/giordano)\
**Post date:** [August 27, 2018, 10:37am UTC](https://discourse.julialang.org/t/offset-when-converting-excel-time-to-unix-time-two-whole-days/14119/5 "2018-08-27T10:37:33Z")

</div>

The next line says “January 0, 1900 actually corresponds to the historical date of December 30, 1899”, so yes, the difference is the sum of these things.

---

<div class="post-metadata">

**Author:** ![slowbrain](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/slowbrain/32/2224_2.png) [@slowbrain](https://discourse.julialang.org/u/slowbrain)\
**Post date:** [August 27, 2018, 12:13pm UTC](https://discourse.julialang.org/t/offset-when-converting-excel-time-to-unix-time-two-whole-days/14119/6 "2018-08-27T12:13:43Z")

</div>

Thanks guys!
