• You should avoid to use strings or integers to store dates. This might help you with your problem.

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

    FROM (VALUES('20130801173009'))x(strDate)

    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