Formatting datetime values returned in a SELECT..FOR XML statement

xxrimexx

New Member
Consider the following table: Orders\[code\]OrderId Date CustomerId 1000 2012-06-05 20:03:12.000 51 1001 2012-06-16 12:02:31.170 48 1002 2012-06-18 19:45:16.000 33\[/code\]When I extract the Order data using FOR XML:\[code\]SELECT OrderId AS 'Order/@Order-Id', Date AS 'Order/ShipDate', CustomerId AS 'Order/Customer' FROM Orders WHERE OrderId = 1000FOR XML PATH ('') \[/code\]I get the following result: \[code\]<Order Order-Id="1000"> <ShipDate>2010-02-20T16:03:12</ShipDate> <Customer>51</Customer></Order> \[/code\]The problem is, the \[code\]ShipDate\[/code\] value in the XML file needs to be in the format \[code\]M/DD/YYYY H:mm:ss PM\[/code\]. How can I change the output of the \[code\]ShipDate\[/code\] in the XML file to the desired format? Any help would be greatly appreciated!
 
Back
Top