• You can format your string with STUFF(). However, I wouldn't advice to convert your column. You should convert the GETDATE()-1 to string or even better, change the column data type to the correct one.

    Here's an example of how to do it both ways.

    SELECT CONVERT( datetime, STUFF(STUFF('201410011112', 11, 0, ':'), 9, 0, ' ')) StringToDate,

    REPLACE( REPLACE( REPLACE( CONVERT( varchar( 16), GETDATE() - 1, 120), '-', ''), ' ', ''), ':', '') DateToString1,

    CONVERT( char( 8), GETDATE() - 1, 112) + REPLACE( CONVERT( char( 5), GETDATE() - 1, 14), ':', '') DateToString2

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2