I'm looking at some legacy VB6 code (years+years old, before my time) which runs a query against an SQL 2005 db. It supplies a date restriction in the WHERE
clause - where the date is given as an integer value as a result of a CLng()
on the Date in VB6.
e.g.
...
WHERE SomeDateField >= 40064
40064 is what VB6 converts today's date to (8th Sep) by doing a CLng()
on it.
However, in T-SQL this integer actually converts to 10th Sep:
SELECT CAST(40064 AS DATETIME)
And so the results aren't as expected.
Anyone know what may cause this difference in conversion between VB and T-SQL?
I'm assured this always worked without problem, and obviously my suggestion is to pass dates in as dates in standard ISO format. But, need to try to find the reason behind this discrepancy starting to occur.