locked
Convert dateformat RRS feed

  • Question

  • How to convert dd//mm/yy format to Date Month Year

    08/06/16 into 08 June 2016 this format i require here, here my data type is varchar

    i am trying to convert using Convert function but its not converting,wt is the issue on this please let me know,or share me the right function to convert this 

    Ex :Select convert(varchar(12),Getdate(),107) from table  

    the above convert function is using here

    Friday, July 22, 2016 12:01 PM

Answers

  • Use CONVERT (Transact-SQL) with format parameter

    SELECT CONVERT(varchar(20), CONVERT(datetime, '08/06/16', 3), 106)


    Olaf Helper

    [ Blog] [ Xing] [ MVP]

    Friday, July 22, 2016 12:05 PM
    Answerer
  • The conversion of a varchar data type to a datetime data type resulted in an out-of-range value.

    it was throghing this above error ,my data type of date column is varchar(8).

    Thanks you

    This will work.Finally

       SELECT Convert(varchar(12),CAST(CONVERT(VARCHAR, getdate(), 101) AS datetime),107) FROM Employ 
       where ISDATE(Getdate()) = 1

    it is taking more time to run the query,Can you provide me any other query for the same results...
    Friday, July 22, 2016 12:09 PM

All replies

  • Use CONVERT (Transact-SQL) with format parameter

    SELECT CONVERT(varchar(20), CONVERT(datetime, '08/06/16', 3), 106)


    Olaf Helper

    [ Blog] [ Xing] [ MVP]

    Friday, July 22, 2016 12:05 PM
    Answerer
  • The conversion of a varchar data type to a datetime data type resulted in an out-of-range value.

    it was throghing this above error ,my data type of date column is varchar(8).

    Thanks you

    This will work.Finally

       SELECT Convert(varchar(12),CAST(CONVERT(VARCHAR, getdate(), 101) AS datetime),107) FROM Employ 
       where ISDATE(Getdate()) = 1

    it is taking more time to run the query,Can you provide me any other query for the same results...
    Friday, July 22, 2016 12:09 PM