Results 1 to 3 of 3

Thread: Date formatting

  1. #1
    Join Date
    Jan 2015
    Posts
    27

    Post Unanswered: Date formatting

    what's the best way to convert this statement to show a format such as 02022013 without slashes or hyphens...

    CONVERT (CHAR(10), A.POKFRM, 112)

  2. #2
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    The best way to format any data (like a date), is to do it on the client. Allowing the user to determine how the data is formatted is always the best answer.

    To format the data as 20130202 (aka YYYYMMDD) which is the most useful way to format data as a string for use in logs, filenames, etc. you can use the Convert(Char(10), A.POKFRM, 112) statement as you posted it.

    If you are determined to cause yourself lots of problems and use the MMDDYYYY format, it can be done even though it is a bad idea for many reasons.

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

  3. #3
    Join Date
    Jan 2013
    Posts
    354
    Provided Answers: 1
    Quote Originally Posted by Khan16 View Post
    what's the best way to convert this statement to show a format such as 02022013 without slashes or hyphens...
    CONVERT (CHAR(10), A.POKFRM, 112)
    To add to what Pat said, the only display format allowed in ANSI/ISO Standard SQL is ISO-8601, "yyyy-mm-dd" and after the Metric System, it is the most common standard in IT. It is embedded in many other standards.

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
  •