Conversion failed when converting date and or time from character string while inserting datetime

0 votes

I tried creating a table as follows:

create table table1(date1 datetime,date2 datetime);

I tried inserting values as below:

insert into table1 values('21-02-2012 6:10:00 PM','01-01-2001 12:00:00 AM');

I encountered this error:

Cannot convert varchar to datetime.

I tried this as a solution :

insert into table1 values(convert(datetime,'21-02-2012 6:10:00 PM',5)

                          ,convert(datetime,'01-01-2001 12:00:00 AM',5));

But still getting the error saying:

Conversion failed when converting date and/or time from character string

Can someone help me with this?

Apr 29 in Other DevOps Questions by Kichu
• 16,850 points
155 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In Other DevOps Questions

+1 vote
2 answers

When do we use Chef or Azure SDK to create VM and deploy in automation

The solution to the automated deployment in ...READ MORE

answered Aug 21, 2018 in Other DevOps Questions by Priyaj
• 58,060 points
427 views
0 votes
1 answer

salt error : “TypeError: coercing to Unicode: need string or buffer, bool found”

You can check the discussion regarding same ...READ MORE

answered Jun 17, 2018 in Other DevOps Questions by shubham
• 7,320 points
1,595 views
0 votes
1 answer

Start vNext build from Powershell and get artefacts

TFS 2015 comes with the new REST API, ...READ MORE

answered Jul 5, 2018 in Other DevOps Questions by Kalgi
• 52,350 points
281 views
0 votes
0 answers
0 votes
0 answers
0 votes
1 answer

Calculate Time Intersection to Correlate Sequences of Independent Events

I think this solution requires a CROSS JOIN implementation. ...READ MORE

answered Oct 26, 2018 in Power BI by Upasana
• 8,620 points
283 views
0 votes
1 answer

How do I UPDATE from a SELECT in SQL Server?

MERGE INTO YourTable T USING ...READ MORE

answered Feb 3 in Database by Vaani
• 5,040 points
36 views
0 votes
0 answers

How do I UPDATE from a SELECT in SQL Server?

INSERT INTO Table (col1, col2, col3) SELECT col1, ...READ MORE

Feb 4 in Database by Vaani
• 5,040 points
12 views
0 votes
1 answer

What is a stored procedure?

A stored procedure is a set of ...READ MORE

answered Feb 4 in Database by Neha
• 6,260 points
79 views
webinar REGISTER FOR FREE WEBINAR X
Send OTP
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP