Fearpig Posted May 17, 2007 Share Posted May 17, 2007 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 More sharing options...
jitesh Posted May 17, 2007 Share Posted May 17, 2007 2007-04-27 00:00:00.000 What is this shown in bold ? I think it should be 2007-04-27 00:00:00 Link to comment https://forums.phpfreaks.com/topic/51815-solved-conversion-failed/#findComment-255286 Share on other sites More sharing options...
Fearpig Posted May 17, 2007 Author Share Posted May 17, 2007 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. Link to comment https://forums.phpfreaks.com/topic/51815-solved-conversion-failed/#findComment-255297 Share on other sites More sharing options...
Fearpig Posted May 17, 2007 Author Share Posted May 17, 2007 Was: UPDATE tbl_Course SET Venue='$Venue',Start_Date='date_formatted' Should have been: UPDATE tbl_Course SET Venue='$Venue',Start_Date='$date_formatted' Looks like I'm having a bad day!! Link to comment https://forums.phpfreaks.com/topic/51815-solved-conversion-failed/#findComment-255330 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.