Hi Travis,
I met this on occasinal basis in the previous versions of Excel and Windows too. Playing with this I came to conclusion that problem is the (custom date to character) formatting that Excel Automation does not represent (in value) properly.
Unfortunately it does not fail every time: sometimes it works, sometimes does not. For instance, I could not reproduce the behavior with your example: it worked fine for me. But then I just opened Excel, new document and made a custom formatting. Then I close Excel, and run your code again. It was enough to reproduce the behavior.
I believe, that your example would start working properly if you change it to:
.ActiveSheet.Cells(1,1).Value = {^1900/01/01}
?.ActiveSheet.Cells(1,1).Value
.ActiveSheet.Cells(2,1).Value = {^1900/01/02}
?.ActiveSheet.Cells(2,1).Value
*-------------
However most likely the problem is related to the 'Excel Oddities' as of
http://j-walk.com/ss/excel/odd/odd02.htm. for years <1901
>To all,
>
>I wrote a fairly complex database import from an Excel file using automation. (Don't ask me to explain the reasons, that's simply what was decided) Anyway, someone brought to my attention recently that some of the dates were coming in incorrectly: they were one day off. I couldn't understand how that could be: the code for this has not changed in over 2 years.
>
>So, I went looking. And sure enough, they were right. The dates were coming in wrong. I couldn't figure it out. Everything in the Excel file looks fine. It's showing the correct dates and it's using the 3/14/2001 format.
>
>So, I went through the command window and typed the following:
>
>o=CreateObject('excel.application')
>o.Visible=.t.
>o.Workbooks.Add()
>ow=o.ActiveSheet
>ow.Cells(1,1).Value = Transform({^1900/01/01})
>?ow.Cells(1,1).Value
>ow.Cells(1,1).Value = Transform({^1900/01/02})
>?ow.Cells(1,1).Value
>o.Workbooks.Close()
>o.Quit()
>
>
>I know this code worked perfectly before. And now in XP, I'm seeing this behavior. What's going on?!! Can someone tell me why this is happening or why MS thinks this behavior is acceptable?
>
>TIA,
>
>Travis