• Excellent. Before we start, a couple of things I recommend you change if it's within your power. First, don't create and delete the Split_XML function every time. Create it once and leave it. Second, change the data type of Date&TimeOfReading to datetime. This will save space in your table and prevent invalid dates being inserted.

    Now, assuming that the date will always appear in the same format, this will work for you:

    ...

    (SELECT CAST(STUFF(STUFF(STUFF(BITOFDATA,13,0,':'),11,0,':'),9,0,' ') AS datetime)

    FROM #SPLITOUTDATA so2

    WHERE so2.INDEX1 = so1.INDEX1 and so2.ROWNUM = 18) AS [Date&TimeOfReading],

    ...

    John