Jump to content

[SOLVED] Conversion Failed


Fearpig

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.