I have a data source with 'datetime' that is plain text and am having issues converting it.
When I attempt to convert it to various date formats and INSERT into a new table, I am getting errors.

data example:

```
"18-07-2015 11:50:30am"

```

source table structure:

```
CREATE TABLE [dbo].[Conv_COMMUNICATIONEXPORT]([datetime] [varchar](255) NULL) 

```

destination table structure:

```
CREATE TABLE [dbo].[TB_X_Attachment]([CreatedDate] [datetime] NULL)

```

error inserting data:

```
Msg 242, Level 16, State 3, Line 4
The conversion of a varchar data type to a datetime data type resulted in an out-of-range value.

```

When I run the following select, the last convert returns an error:

```
SELECT CONVERT(VARCHAR(30), GETDATE(), 120) ,getdate()  ,CONVERT(DATE, CONVERT(VARCHAR(40), '01-01-2000'), 120)

```

When I run the following into the table, there is success:

```
INSERT INTO TB_X_Attachment (CreatedDate)
CONVERT(DATE, CONVERT(VARCHAR(30), '2000-01-01'), 120) AS WORKS 

```

None of the following conversion attempts works when trying to insert:

```
SELECT      ce.[datetime] AS VARCHAR_DATETIME,
CONVERT(VARCHAR(10), CE.[datetime], 120),
CONVERT(char(10), CONVERT(VARCHAR(10), CE.[datetime], 120),120),
CONVERT(VARCHAR(10),CONVERT(char(10), CONVERT(VARCHAR(10), CE.[datetime], 120),120),120),
CONVERT(VARCHAR,(CONVERT(VARCHAR(10), CE.[datetime], 120))) ,   
CONVERT(VARCHAR(10), CE.[datetime], 120)
FROM        Conv_ATTACHMENTEXPORT ae
INNER JOIN  Conv_COMMUNICATIONEXPORT ce
            ON ae.[attachment record id] = ce.[communication id] 

```

See image below of the results of the above convert trys
[![last column is format that will insert](https://i.stack.imgur.com/U6LNX.png)](https://i.stack.imgur.com/U6LNX.png)

I think if I can reverse the output to YYYY-MM-DD it may work. All the convert attempts dont want to set the format to this. How can I reverse the output to YYYY-MM-DD?