This is something I haven’t seen covered anywhere else so in this article I’ll have a detailed look at how the managed metadata field functionality works so that we can correct these problems when creating list definitions that use managed metadata fields.
When we add a managed metadata column through the UI Share Point creates two fields: Additionally two event receivers are added to the list if they are not there already.
I’ve been working with the managed metadata functionality provided in Share Point 2010 fairly extensively over the past few months.
While it is a great feature and works well when used through the UI it has several rough edges that can cause problems when you are deploying features that use managed metadata fields.
BTW, when I display the two dates in an alert, they show as exactly the same.
My code: will be set with hours, minutes, seconds and milliseconds to zero, but date1 will have them set to the time that date1 was created.
Maybe it would be simpler to just compare date and not time.
I am not sure how to do this either, and I searched, but I couldn't find my exact problem.
JSLint is a great tool for catching things like a missing radix and many other things that can cause obscure and hard to debug errors.
In the case of lookup fields and managed metadata fields (which inherit from the lookup field) these require an additional step to ‘wire them up’ to the correct lookup data programmatically.
Wictor Wilén explains this process in his excellent article on ‘How to provision Share Point 2010 Managed Metadata columns’.
To get rid of the hours, minutes, seconds and milliseconds on date1 do the following: Be careful : if date1 and date2 are in winter and summer, and you plan to iterate from one to the other with add Days(1), the problem is that they won't have the same timezone because of the daylight saving, so the last compare that should give equal dates will not work because the two date are not really at :0.
I know this is an old question, but it comes up first in google when searching. This will give incorrect answers if the user is not in the same time zone as the creator of the date object.