This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Please use real words when posting to the forums. Abbreviations such as "diff" in place of "difference" only serve to make your posts more difficult to read and less likely to generate useful responses.
David Newton wrote:I can't reproduce this; if I have different dates, I don't get 0 for the difference between the times.
Agreed. If the two days were only a day apart, then I would have made the argument that maybe the hours, minutes, and seconds, along with rounding down, may be the cause. But the example given is a month apart... something else is happening here.
Maybe you can show us the code that initializes dat1 and dat2?
Here lies your problem. The lower case 'm' stands for minutes, not month. You should use upper case 'M' instead. And you should only use two 'M's, not three, since three (ie 'MMM') means the month spelled out as a word instead of a number.
Try this instead:
As a tip for future troubleshooting. When you encounter problems, always try to print out the different variable values in your code, to see if they are what you expect. If you would have printed out the dat1 and dat2 values you would have seen that the dates were wrong, thus you would know that the bug is in the parsing of the date.
Joined: Dec 11, 2009
thankyou so much
you explained it very well
and also thankyou to all people
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com