July 8, 2014 at 12:06 pm
I have an xml with a date/time with offset:
<start>2014-07-01T13:00:00-06:00</start>
I'm reading this through openxml and my server is in CST:
declare @dt datetime2(0)
select @dt = start
from openxml ( @idoc, '/root', 1 )
with ( start datetime2 'start' )
When I query for @dt I get: 2014-07-01 19:00:00, which is the date/time in UTC, because of the 6-hour offset.
My understanding is that the XML is in UTC and the offset is provided to identify the time zone where the data was originated. I need to read the data such that is returns 2014-07-01 13:00:00.
Can someone please explain what is that I'm doing wrong?
Thanks
July 11, 2014 at 6:05 pm
In
select @dt = start
from openxml ( @idoc, '/root', 1 )
with ( start datetime2 'start' )
Try changing the DATETIME2 portion to DATETIME2(0) to see if keeping the data type consistent helps.
OR In this case since you have the zone where the time is maybe try substituting datetime2 with DATETIMEOFFSET in the code , then in your select cast this to SMALLDATETIME. See if this helps you.
----------------------------------------------------
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply