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 ?

  • Why are these nested SQL Server transactions throwing a mismatch error if there is a rollback?
  • SQL Server Date Format India to US
  • Fast query for end user report
  • How to simulate UNPIVOT in Access 2010?
  • Table Value optional parameter
  • How to enforce this constraint in sql server
  • 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'))
    

  • Why is SQL Server misinterpreting this ISO 8601 format date?
  • My Select SUM query returns null. It should return 0
  • Execute .sql files that are used to run in SQL Management Studio in python
  • Using sub query in in group by sql server
  • SQL Partition by Overlapping dates
  • SQL Server stored procedure: iterate through table, compare values, insert to different table on value change
  • 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.