× {{alert.msg}} Never ask again
Get notified about new tutorials RECEIVE NEW TUTORIALS

ToOADate(); Convert Julian Date Excel

Codementor User
Feb 05, 2015
<p>If you are converting numbers to Framework DateTime instances, it is likely you are after the <strong>static</strong> method on the DateTime struct.</p> <pre><code> DateTime dt = DateTime.FromOADate(23456); </code></pre> <p>This method needs to be scoped to DateTime. In my example, the result is 20 March 1963.</p> <p>There is also an <strong>instance</strong> method on DateTime which does the reverse...</p> <pre><code> double d = dt.ToOADate(); </code></pre> <p>The result in this case is 23456. </p> <p>Your code indicates that you are trying to call it as an <strong>instance</strong> method on a <strong>int</strong>, and this will not work. The compiler is telling you that there is no such method on the int primitive. </p> <p>Try instead...</p> <pre><code> var test = 41725; DateTime test2 = DateTime.FromOADate(test); </code></pre> <p>And you'll get 27 March 2014.</p> <p>This tip was originally posted on <a href="http://stackoverflow.com/questions/23347645/ToOADate();%20Convert%20Julian%20Date%20Excel/23347924">Stack Overflow</a>.</p>
comments powered by Disqus