title: Excel Passing Wrong Date Value to VBA Function
body: <p>I have a worksheet with Date values. Excel interprets them correctly as Dates.</p>
  
  <p>I have a VBA function that accepts a Date parameter.</p>
  
  <p>When I call this function from the worksheet, sometimes it works correctly, and sometimes it doesn't. When I set a breakpoint in the function to examine the value passed in to the function from a cell that is incorrect, I discover that the wrong date is passed to the function--it's a day off from what should be passed to the function. The time value is correct.</p>
  
  <p>This occurs in random places on the worksheet. In fact, in one cell that it didn't work correctly in yesterday, it now works correctly today.</p>
  
  <p>The time portion of the value doesn't seem to make a difference. It can be 22:00 hours, 08:00 hours, it's still off by a day.</p>
  
  <p>Does this make any sense to anyone? I am seriously perplexed.</p>
  
  <p><strong>Edit:</strong></p>
  
  <p>I didn't post any code because I don't find it to be a code issue. But here's the function signature:</p>
  
  <pre><code>Function timeToDecimal(time As Date, semanticTimeFormat As String) As Double
  </code></pre>
  
  <p>Setting a breakpoint on the first line of executable code in the function, I see that <code>time</code> is, for example, <code>1/1/1900 1:09:25 PM</code>, when, on the worksheet it is clearly <code>1/2/1900  1:09:25 PM</code>.</p>
  
  <p>The issue isn't the VBA code I've written. The issue is Excel's passing of the data to the function. Is there some quirk I am unfamiliar with in the interface between Excel and VBA?</p>