Date truncation problem

  • I had to convert "2005-05-17 16:35:49.000" date to string using

    CAST(a.ps_ActImplDate AS varchar(20)), 'Not Assigned'), since I had to assign "not assigned" to all null dates

    Problem here is when I am displaying date in string format it is only displaying like "May 17 2005 4:35PM" missing seconds part. I need everything because I need to query using same date on other table. How to convert datetime to string without any truncation

    Following a snapshot of how it each datetime looks before and after conversion

    2005-05-17 16:35:49.000 May 17 2005 4:35PM

    2005-05-17 16:27:03.000 May 17 2005 4:27PM

    2005-05-17 16:27:03.000 May 17 2005 4:27PM

    2005-05-17 16:35:48.000 May 17 2005 4:35PM

  • When you CAST'ed the DATETIME you lost the seconds.  You cannot get them back from already CAST'ed values.  However, Try this conversion for FUTURE date conversions IF you need seconds...  SELECT CONVERT(VARCHAR(20), @Date, 109)



    Good Hunting!

    AJ Ahrens


    webmaster@kritter.net

  • Maybe I'm wrong but : 2005-05-17 16:35:48.000 May 17 2005 4:35PM

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply