Conversion failed when converting datetime from character string.

Conversion failed when converting datetime from character string.

Page 1 of 1

5 Replies - 5889 Views - Last Post: 14 January 2011 - 03:08 PM Rate Topic: -----

#1 YOGESH_JAIN  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 08-January 11

Conversion failed when converting datetime from character string.

Posted 12 January 2011 - 05:27 AM

[insert into tblOfficersTracking values(1,1,'IAS','yogi','The 1985-batch IAS officer of the Kerala cadre is now Joint Secretary in the Department of Information Technology.',05/01/2011,1,02/01/2011,1,02/01/2011)]



This Query Giving Me the Error is"Conversion failed when converting datetime from character string."



How Can I Solve this.
Is This A Good Question/Topic? 0
  • +

Replies To: Conversion failed when converting datetime from character string.

#2 P4L  Icon User is offline

  • Your worst nightmare
  • member icon

Reputation: 34
  • View blog
  • Posts: 2,788
  • Joined: 07-February 08

Re: Conversion failed when converting datetime from character string.

Posted 12 January 2011 - 06:46 AM

What database are you using?
Was This Post Helpful? 0
  • +
  • -

#3 YOGESH_JAIN  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 08-January 11

Re: Conversion failed when converting datetime from character string.

Posted 12 January 2011 - 09:18 PM

Sql Server 2005
Was This Post Helpful? 0
  • +
  • -

#4 P4L  Icon User is offline

  • Your worst nightmare
  • member icon

Reputation: 34
  • View blog
  • Posts: 2,788
  • Joined: 07-February 08

Re: Conversion failed when converting datetime from character string.

Posted 13 January 2011 - 07:21 AM

Try this:

insert into tblOfficersTracking values(1,1,'IAS','yogi','The 1985-batch IAS officer of the Kerala cadre is now Joint Secretary in the Department of Information Technology.',2011-05-01,1,2011-02-01,1,2011-02-01)



SQL Server uses the YYYY-MM-DD format for dates. That's why it was not able to convert the format.
Was This Post Helpful? 0
  • +
  • -

#5 Guest_forcedsterilziationsforall*


Reputation:

Re: Conversion failed when converting datetime from character string.

Posted 14 January 2011 - 03:03 PM

doesn't the date need to be in single quotes? I've always done it that way and never had to worry about whether it was YYYY-MM-DD or MM-DD-YYYY.
Was This Post Helpful? 0

#6 rgfirefly24  Icon User is offline

  • D.I.C Lover
  • member icon


Reputation: 267
  • View blog
  • Posts: 1,476
  • Joined: 07-April 08

Re: Conversion failed when converting datetime from character string.

Posted 14 January 2011 - 03:08 PM

Sql Server does require it to be in single quotes. It also doesn't matter if its in YYYYMMDD format or MM-DD-YYYY format. Sql Server sees dates as Strings.

This post has been edited by rgfirefly24: 14 January 2011 - 03:09 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1