Results 1 to 2 of 2
  1. #1
    Join Date
    Nov 2011
    Posts
    24

    Question Unanswered: How to convert this date

    Hello everyone, hope all is well

    in sql i needed to know how to convert the date YYYYMMDDHHMMSS TO CYYMMDD

    thanks in advance!

  2. #2
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    Code:
    DECLARE @d		DATETIME = GetDate()
    
    SELECT @d, CONVERT(CHAR(8), @d, 112)
    ,  CONVERT(VARCHAR, @d, 112) + REPLACE(CONVERT(VARCHAR, @d, 114), ':', '')
    -PatP
    In theory, theory and practice are identical. In practice, theory and practice are unrelated.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •