I am using an object objCurrentWarrantStatus to get the database datetime which is #11/3/2016 6:36:49 AM#. I would like to compare it with the date I have in xml document which is
<warrantstatusdate>2016-11-03
Xml date does not have time while database date has time in it.
My code is failing for the reason that these two are not of the same type. Comparing #11/3/2016 6:36:49 AM# to 2016-11-03 is not working.
The code I have below is supposed to pass (not generate an error) but since the database date also have time in it I am not able to compare it to the date in xml document because xml document date has no time in it. This is making my code to fail. If I can figure out what to change so these two dates are in the same formate, then my code will not fail.
What do I need to change so that the database date which has time in it and the xml date which has no time in it are in the same format to compare them?
objCurrentWarrantStatus = Msc.Integration.Mncis.Library.v4.WarrantStatus.GetCurrent(Trim(objXMLInputDoc.DocumentElement.SelectSingleNode("msc:WarrantNumber/msc:ID", objXMLNameSpaceManager).InnerText))
If (Not objCurrentWarrantStatus Is Nothing) _
AndAlso ((objXMLInputDoc.DocumentElement.SelectSingleNode("msc:CurrentWarrantStatus/msc:WarrantStatusTypeText/@code", objXMLNameSpaceManager).InnerText <> objCurrentWarrantStatus.TypeCodeWord) _
Or (CDate(objXMLInputDoc.DocumentElement.SelectSingleNode("msc:CurrentWarrantStatus/msc:WarrantStatusDate", objXMLNameSpaceManager).InnerText) <> objCurrentWarrantStatus.Date)) Then
strErrorResponse = "The date used for CurrentWarrantStatus was incorrect."
objXMLInputDoc.DocumentElement.SetAttribute("error", strErrorResponse)
End If
Here is the property for the date
Public Property Date As Nullable(Of DateTime)
Get
Set
What I have tried:
I have tried the following code but it is failing because the date in the database (objCurrentWarrantStatus) has time in it while the date in xml document does not have time. So these cannot be compared.
objCurrentWarrantStatus = Msc.Integration.Mncis.Library.v4.WarrantStatus.GetCurrent(Trim(objXMLInputDoc.DocumentElement.SelectSingleNode("msc:WarrantNumber/msc:ID", objXMLNameSpaceManager).InnerText))
If (Not objCurrentWarrantStatus Is Nothing) _
AndAlso ((objXMLInputDoc.DocumentElement.SelectSingleNode("msc:CurrentWarrantStatus/msc:WarrantStatusTypeText/@code", objXMLNameSpaceManager).InnerText <> objCurrentWarrantStatus.TypeCodeWord) _
Or (CDate(objXMLInputDoc.DocumentElement.SelectSingleNode("msc:CurrentWarrantStatus/msc:WarrantStatusDate", objXMLNameSpaceManager).InnerText) <> objCurrentWarrantStatus.Date)) Then
strErrorResponse = "The date used for CurrentWarrantStatus was incorrect."
objXMLInputDoc.DocumentElement.SetAttribute("error", strErrorResponse)
End If