troubleshooting Question

Convert string to date

Avatar of lulu50
lulu50Flag for United States of America asked on
Microsoft SQL ServerMicrosoft SQL Server 2008SQL
5 Comments1 Solution94 ViewsLast Modified:


I have an excel sheet that has a data from a vendor.
One of the field that I need from the excel sheet is the Submit_Date.
they have it as string nvarchar "February 12, 2015 2:07:21 PM EST"
I have created a table with that field as datetime.

the problem that I'm having when I do my import from excel to SQL. it import the Submit_Date as string from excel
but my table " ClearQuestReport" has Submit_Date as datetime .
when I run my stored Procedure I get this error

Msg 241, Level 16, State 1, Procedure CQ_ClearQuestReport, Line 24
Conversion failed when converting date and/or time from character string.

This is my stored Procedure.

what I need is to convert Submit_Date field from string to datetime field when I import the data into my table "ClearQuestReport"

UPDATE ClearQuestReport
id =,
Headline = ClearQuestReport_Import.Headline,
Description = ClearQuestReport_Import.Description,
Submited_By = ClearQuestReport_Import.[Submited By],
Submit_Date = ClearQuestReport_Import.Submit_Date
FROM ClearQuestReport
    INNER JOIN ClearQuestReport_Import ON =

--This will insert all non matching records
INSERT INTO ClearQuestReport(id,Headline,Description,Submited_By,Submit_Date)
SELECT id,Headline,Description,[Submited By],Submit_Date
FROM ClearQuestReport_Import
                 FROM ClearQuestReport
                 WHERE ClearQuestReport.Id = ClearQuestReport_Import.Id)

SELECT * FROM ClearQuestReport

Thank you
Olaf Doschke
Software Developer

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 5 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros