Question
1
Replies
117
Views
Virgin Media Ireland Limited
Posted: November 2, 2018
Last activity: December 5, 2018
Closed
GetSpecifiedTimeOnDate function returning date that is 24 hours off
I have been having an issue with the function GetSpecifiedTimeOnDate. We have been using it to convert DateTime objects back to GMT times.
However the dates can be out by 24 hours.
In this case, Testing with a DateTime object it is returning the wrong Date, while using a date object we get the correct result.
We began using a DateTime object to avoid this exact scenario, is this a bug? Why am I getting this incorrect value?
Hello,
The function GetSpecifiedTimeOnDate definition specifies that the first parameter is a date stamp, not date time (which is what it specifies that it returns). So you are passing in something the code doesn't expect. I don't know exactly why it doesn't digest it correctly but am not surprised given that it's not made to do so. If I had to hazard a guess, you're falling on the wrong side of midnight GMT, based on your other parameter values.
I don't understand your usecase. If you have a date time stamp already, why are you calling that function at all? The purpose of the function is to take a given date, hour, minute, second, and time zone and to get a valid datetime stamp for that combination. If you already have a datetime value, presumably the rest of the parameters are invalid.
Thanks,
- Mike