Home Forums SQL Server 2014 Administration - SQL Server 2014 Problem Converting DATE. Trying to Purge Data Oldest than 30 days from Performance Counter Table where date column is char (24) RE: Problem Converting DATE. Trying to Purge Data Oldest than 30 days from Performance Counter Table where date column is char (24)

  • dfd.francisco 53179 - Friday, August 10, 2018 2:05 AM

    Hi try a workarround, deleting and recreating the table with the column in DATETIME, but then the performance counter BLOWS :pinch:

    What do you mean by that?  If you have the option to redesign the table then that's what you should do.  Store dates as dates.  Even if performance is worse, it's still working as it should.  If you can't change the table, then try taking the hyphens out of the stored dates.  I couldn't replicate that myself, but I think I've heard reports that sometimes the hyphen stops the date from being convertible.

    SELECT CAST('2018-08-10 09:16:57.803' AS datetime)
    SELECT CAST('20180810 09:16:57.803' AS datetime)

    John