raberana
raberana

Reputation: 11816

Excel macro populates a date cell but its not equal to a real date cell

I have a function that returns an ODate (date in a double data type) from a called API.

Private Function CoreCompute(....)
   .... 
   CoreCompute = oXmlHttp.ResponseText //sample return: a double value 41902, which is equivalent to 2014/09/20
End Function

When this is called to a cell with a Format of Date, it is not transformed to a date value and not equal to a true date cell.

How can I output a value in a cell which can be compared to an actual date cell value?

PS. Q17 is actually Q16

Simulation of the problem. Q17 is actually Q16

Upvotes: 1

Views: 96

Answers (1)

Sam
Sam

Reputation: 7303

Try CoreCompute = CDbl(Trim(oXmlHttp.ResponseText))

This probably works because your response is a string and it could have whitespace included.

Trim will remove the whitespace

CDbl will ensure that value is converted to a number type.

Upvotes: 1

Related Questions