Results 1 to 4 of 4
  1. #1
    Join Date
    Jul 2014
    Posts
    4

    Question Unanswered: Changing Date format and casting as Varchar?

    My current Query takes the DATE value stored in P.CreatedDate and makes it VARCHAR, then stores it in the table. I need to format this to return YYYYMMDD. How would I go about this?

    Current Code:
    Code:
    CAST(P.CreatedDate AS VARCHAR) AS DateEntered,

  2. #2
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    Code:
    Convert(CHAR(8), p.CreatedDate, 112)
    -PatP
    In theory, theory and practice are identical. In practice, theory and practice are unrelated.

  3. #3
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Why would you want to store a date as anything other than a date?
    Sounds like a presentation issue to me.
    George
    Home | Blog

  4. #4
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    It is a presentation issue, but aidenkael (the OP) still needs to discover that.

    -PatP
    In theory, theory and practice are identical. In practice, theory and practice are unrelated.

Tags for this Thread

Posting Permissions

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