Search code examples
sqlsp-send-dbmail

SQL sp_send_dbmail adding T in date column


I have a sp_send_dbmail query that emails a list of results.

Everything works great except the date column is getting a T added where the space is.

It shows fine when i run the query, but when it is used in the sp_send_dbmail its adding the T.

Example

2014-11-06T16:06:24.100

Should Be

2014-11-06 16:06:24.100

Query in the sp_send_dbmail

SELECT
td = [Status],'',
td = [Number],'',
td = [Date] ,'',
td = [Error Message]
FROM [Views].dbo.Errors   
ORDER BY Date

Solution

  • You need to format your date-column with CONVERT():

    SELECT
    td = [Status],'',
    td = [Number],'',
    td = CONVERT(varchar(25), [Date], 21),'',
    td = [Error Message]
    FROM [Views].dbo.Errors   
    ORDER BY Date