sqlserver format date time

I am not familar with sql server why i have the following error

Conversion failed when converting date and/or time from character string.
...
values (1, 'P' + char(10) + 'd' + char(10) + 'inst',
 CONVERT(VARCHAR(24),'18-01-2016 11:29:27',113))

the code for 13 is = dd mon yyyy hh:mi:ss:mmm (24h) is it possible wrong code ?

  • Sql Server CTE “multi- part identifier could not be bound.”
  • how to build sql server 2008 datetime object and insert it using perl DBI
  • System.ComponentModel.Win32Exception: The wait operation timed out
  • Deploy multiple instance of reporting services or connect to multiple versions of DLLs
  • Is there a way to arbitrarily pick one result in SQL query without doing GROUP BY
  • Why can't I simply add an index that includes all columns?
  • I checked this answer also didnt work

    values (1, 'P' + char(10) + 'd' + char(10) + 'inst',
     format('18-01-2016 11:29:27','MM/dd/yyyy HH:mm:ss'))
    

  • Fastest way to insert 30 thousand rows in a temp table on SQL Server with C#
  • Why does this Sql Statement (with 2 table joins) takes 5 mins to complete?
  • How to Replace Multiple Characters in SQL?
  • How do I find a default constraint using INFORMATION_SCHEMA?
  • Best pattern for storing (product) attributes in SQL Server
  • SSRS column and line chart?
  • 2 Solutions collect form web for “sqlserver format date time”

    First of all the target type of CONVERT should be DATETIME

    The format code you’ve tried expects the month as word (mon != mm)

    SELECT CONVERT(DATETIME,'18 jan 2016 11:29:27',113);
    

    You might use one of these:

    SELECT CONVERT(DATETIME,'18-01-2016 11:29:27',103)
    SELECT CONVERT(DATETIME,'18-01-2016 11:29:27',104)
    

    I believe its inserting as varchar, u can use this script

    SELECT CONVERT(varchar(24),'18-01-2016 11:29:27',120)
    
    MS SQL Server is a Microsoft SQL Database product, include sql server standard, sql server management studio, sql server express and so on.