I know there are many questions of this kind, and I have already seen another questions as this one: Conversion failed when converting date and/or time from character string while inserting datetime
But the main thing is that I cannot convert a specific string to datetime using any format using SQL Server. Here is what I'm trying to do:
DECLARE @1 AS VARCHAR(500)
SET @1 = '18/03/2015 08:07:25 a.m.'
SELECT CONVERT(DATETIME, @1, 131)
This is not working, even if i tried with several formats as specified here: https://msdn.microsoft.com/en-us/library/ms187928.aspx
For what I've tried it just works with 131 format if the string containing the datetime is on 24 hour format, like this:
DECLARE @1 AS VARCHAR(500)
SET @1 = '18/03/2015 08:07:25'
SELECT CONVERT(DATETIME, @1, 131)
Does anyone know how can I do to convert that string to datetime as I need?.
Many thanks for your help.