Date format

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Manikgisl
    New Member
    • Oct 2008
    • 37

    Date format

    hi

    any help me format the date in back end

    In sql back end have so many formats for date


    i want make into single format while retriving in sql


    Any possibility is there ??

    for eg:
    in the back end i have following dates
    18-11-2008 2:35:19 PM
    11-18-2008 2:35:19 PM
    18/11/2008 2:35:19 PM
    11/18/2008 2:35:19 PM


    To make in Specific Format to Single format


    its possible
  • ck9663
    Recognized Expert Specialist
    • Jun 2007
    • 2878

    #2
    You will have a problem with 09/08/2008. This could be interpreted in two ways. Sept 8 or Aug 9.

    Here are some of my notes regarding dates.

    Try analyzing the pattern and see if it's mm/dd/yyyy or dd/mm/yyyy. Based on your example it's mixed. Try to make it a single format first then convert the column to smalldate or datetime, depending on your requirement.For that read my old notes, here

    -- CK

    Comment

    • Manikgisl
      New Member
      • Oct 2008
      • 37

      #3
      Originally posted by ck9663
      You will have a problem with 09/08/2008. This could be interpreted in two ways. Sept 8 or Aug 9.

      Here are some of my notes regarding dates.

      Try analyzing the pattern and see if it's mm/dd/yyyy or dd/mm/yyyy. Based on your example it's mixed. Try to make it a single format first then convert the column to smalldate or datetime, depending on your requirement.For that read my old notes, here

      -- CK

      But the problem is we have dates in Varchar instead Datetime

      While Converting Varchar To Datetime All four formats are unable to

      Convert

      ie

      select Convert(Datetim e,'18-11-2008 2:35:19 PM',102) -- error


      "The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value."

      select Convert(Datetim e,'11-18-2008 2:35:19 PM',102) ok


      select Convert(Datetim e,'18/11/2008 2:35:19 PM',102) Error

      "The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value."

      select Convert(Datetim e,'11/18/2008 2:35:19 PM',102) ok

      Comment

      • ck9663
        Recognized Expert Specialist
        • Jun 2007
        • 2878

        #4
        Double post. I replied on your new post, here

        -- CK

        Comment

        Working...