I have a piece of code that is giving me an unexpected output when taking a json date parameter. (this has been noticed as the software is being used in a different timezone to the one it was created in)
the html is a basic jquery datepicker field, so nothing wrong with that. I am just trying to match the date selected with a date in the database.
the JSON datetime that goes into the WebMethod FindDuplicates
is in the correct format
2015-09-17T00:00:00.000Z
the javascript that calls the webservice is simply:
findDuplicates : function(options, success, error) {
if(''+options.name == '' && ''+options.dateToCompare == '') {
success&&success([], 'success', null);
return;
}
return $software.__call_ajaxws('/webservices/FindDuplicates', { nameToMatch: options.name || null, dateToCompare: options.dateToCompare }, null, success || void (0), error || void (0), { elContent: 'Searching for duplicate records' });
}
in this (the none working) code, the variable dateToCompare
<WebMethod(), ScriptMethod(ResponseFormat:=ResponseFormat.Json), PrincipalPermission(SecurityAction.Demand, Authenticated:=True)> _
Public Function FindDuplicates(ByVal nameToMatch As String, ByVal dateToCompare As Nullable(Of DateTime))
Dim someValue as String = "Foo"
at the point Dim someValue as String = "Foo"
the value of dateToCompare
has become 2015-09-17 09:00:00
whereas if I change the type of dateToCompare
to a string it shows correctly as 2015-09-17 00:00:00
for some reason i cant work out, when casting/converting the parameter to a DateTime it decides to add the timezone of the server to the date, thereby sending an incorrect date to the comparison function meaning that a DB stored value of 2015-09-17 00:00:00
wont ever compare because it is being compared with 2015-09-17 09:00:00
is there someway I can stop the conversion process of string to datetime adding the timezone of the server?