• As previously stated you can use CAST or CONVERT. But like many items in T-SQL "It depends". As an example ... be aware of your system date format, and of course the format of the actual data.

    DECLARE @T VARCHAR(40)

    SET DATEFORMAT dmy

    SET @T = '2012-08-05 09:13:50.053'

    SELECT CAST(@T AS DATETIME)

    SET @T = '20120805 09:13:50.053'

    SELECT CAST(@T AS DATETIME)

    Results:

    2012-05-08 09:13:50.053

    2012-08-05 09:13:50.053

    As is obvious the results are dramatically different. If you would post a sample of your actual data, and your systems dateformat someone may be able to assist you furter.

    If everything seems to be going well, you have obviously overlooked something.

    Ron

    Please help us, help you -before posting a question please read[/url]
    Before posting a performance problem please read[/url]