Page 1 of 1

Syntax error converting datetime from character string. (sev

Posted: Thu Mar 12, 2009 7:44 am
by elpepefontana
i have 2 programs running mssql databases, i've wrote some functions to extract the data i need from each of the databases.
when i'm trying to wirit some data to one of these db i get the subject's error.
i'm using this insert sentence:
$query = "insert into VENT_NPCA values (
'1',
'NPC',
'" . $entr1[$a]['docnum'] . "',
'convert(datetime," . strtolower($entr1[$a]['fechadoc']) . ")',
'" . $entr1[$a]['plid'] . "',
'" . $entr1[$a]['moneda'] . "',
'" . $entr1[$a]['condpago'] . "',
'',
'" . $entr1[$a]['docnum'] . " - " . $entr1[$a]['notas'] . "',
'" . $entr2[$b]['TINP_LISTA_PRECVTA'] . "',
'" . $entr2[$b]['TINP_CANT_DESC_CAB'] . "',
'" . $entr2[$b]['TINP_CANT_DESC_REN'] . "',
'" . $entr2[$b]['TINP_DTONETBRU_CAB'] . "',
'" . $entr2[$b]['TINP_DTONETBRU_REN'] . "',
'convert(datetime," . strtolower($entr1[$a]['convertido']) .")',
'" . $entr1[$a]['domicilio'] ."',
'1',
'" . $entr1[$a]['flete'] . "',
'" . $entr2[$b]['TINP_ES_FACTURABLE'] . "',
'" . $entr2[$b]['TINP_DISCRIM_IMP'] . "',
'" . $entr1[$a]['total'] . "',
'" . $entr1[$a]['total'] . "',
'1',
'convert(datetime," . strtolower($entr1[$a]['fechadoc']) . ")',
'1',
'1',
'NULL',
'NULL',
'" . $entr2[$b]['TINP_POR_MAX_EXCES'] . "',
'" . $entr2[$b]['TINP_INDICADOR_DEP'] . "',
'1',
'convert(datetime," . @getdate() . ")',
'NULL',
'" . $entr1[$a]['npcv1'] . "',
'" . $entr1[$a]['npcv2'] . "',
'" . $entr1[$a]['npcv3'] . "',
'" . $entr1[$a]['npcv4'] . "',
'" . $entr1[$a]['npcv5'] . "',
'" . $entr1[$a]['npcv6'] . "',
'0',
'0',
'0',
'0',
'1',
'NULL',
'0',
'" . $entr1[$a]['vehiculo'] . "',
'" . $entr1[$a]['distribuidor'] . "'
)";both $entr1 and $entr2 are the result of a previous function that extracts the data, process it (cut ".",and make all data uppercase, the target program save all data in uppercase) and creates multidimensional arrays.
when i print the dates this is what i get:
Can the uppercase convertion generate such an error, is my convert syntax wrong?
can somebody help me?

Re: Syntax error converting datetime from character string. (sev

Posted: Fri Mar 13, 2009 9:56 am
by elpepefontana
ok i've worked it out

Re: Syntax error converting datetime from character string. (sev

Posted: Fri Mar 13, 2009 9:58 am
by susrisha
great.. tell us how..