I have a DateTime object that I want to compare with the sql datetime field in the where clause. I am currently using:
"where (convert( dateTime, '" & datetimeVariable.ToString & "',103) <= DatetimeField)"
But I believe datetimeVariable.ToString will return a different value depending on the culture in which the system works.
How would you handle this, so that is cultural independence?
EDIT: I will not use paramatised sql in this code ...
EDIT: Parmesan's next comment on one of the answers looks like the best way:
"where (convert( dateTime, '" & datetimeVariable.ToString( "s" ) & "',126) <= DatetimeField)"
source share