Home Forums SQL Server 2005 T-SQL (SS2K5) datetime => how to have complete date with 00:00:00.000 RE: datetime => how to have complete date with 00:00:00.000

  • One way I often do this:

    CREATE TABLE #MyTable

    (

    MyDate DATETIME

    )

    INSERT INTO #MyTable

    SELECT '2008-10-28 11:04:04.207' UNION ALL

    SELECT '2009-03-30 13:26:10.433' UNION ALL

    SELECT '2009-01-16 14:06:20.033'

    SELECT MyDate,

    DATEADD(dd, DATEDIFF(dd, 0, MyDate), 0) MyDate_DateOnly

    FROM #MyTable

    DROP TABLE #MyTable

    Hope this helps.

    Cheers,

    Simon 🙂