Jump to content

Recommended Posts

Hello, can someone have a quick look at this for me....

 

Thanks to jitesh I have managed to convert my string entered on a form

from 27/04/2007 to 2007-04-27 00:00:00.000

but when I try to save this value to an SQL datetime field I get the following error:

 

Warning: odbc_exec() [function.odbc-exec]: SQL error: [Microsoft][ODBC SQL Server Driver][sql Server]Conversion failed when converting datetime from character string., SQL state 22008 in SQLExecDirect in D:\Intranet v3\Training\Process_Edit_Course.php on line 37

 

Is there a way to covert my string into a datetime before I try to upload it or can anyone think of a way round this?

 

Thanks for your help!

Link to comment
https://forums.phpfreaks.com/topic/51815-solved-conversion-failed/
Share on other sites

Hello again Jitesh!

 

When I look at the SQL table in SQL manager then I can see the dates as:

"mm/dd/yyyy hh:mm:ss AM"

 

However if I pull a date out of the database and leave the formatting as it is then it shows as:

"yyyy-mm-dd hh:mm:ss.000" 

 

I'm guessing that the .000 is decimals of a second but I'm not sure.

I've tried both of the formatting styles but in both cases I get the error message I mentioned above. I've also tried "yyyy-mm-dd hh:mm:ss" but this still gets the same error message.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.