Home > Archive > MS SQL XML > January 2006 > FOR XML: date returned without timezone









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author FOR XML: date returned without timezone
Martin Szugat

2006-01-04, 9:23 am

I'm querying a table with a datetime field using SELECT ... FOR XML. The
dates are returned in the following format:

<updated>2006-01-04T11:52:52.403</updated>

Is there any possiblity to add the timezone information to it? The result
should look as follows:

<updated>2006-01-04T11:52:52.403Z</updated>

The SQL statements looks like

SELECT date AS updated
FROM articles FOR XML PATH('entry')

Best regards

Martin
Martin Szugat

2006-01-05, 3:23 am

I found a solution:

CONVERT(VARCHAR, date, 126) + 'Z' AS updated

126 is the style code for the ISO8601 date representation, i.e. XML
representation.

"Martin Szugat" wrote:

> I'm querying a table with a datetime field using SELECT ... FOR XML. The
> dates are returned in the following format:
>
> <updated>2006-01-04T11:52:52.403</updated>
>
> Is there any possiblity to add the timezone information to it? The result
> should look as follows:
>
> <updated>2006-01-04T11:52:52.403Z</updated>
>
> The SQL statements looks like
>
> SELECT date AS updated
> FROM articles FOR XML PATH('entry')
>
> Best regards
>
> Martin

Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2008 droptable.com