Using date/time field in direct sql command
Using date/time field in direct sql command
(OP)
Hi!
I've got a problem!
I have a form on which there's a date/time field. and a button. When I press the button fires an active link and it execute a direct sql action making an update on database.
The command is:
Update LEOFRA_STORICO_TRANS
set DATA_CESSAZIONE= $Data Appo$
where IDTT=$IDTT$ and ORDINE_TRANS=(($Ordine Trans$)-1).
Now, everytime I press the button there is an error:
ERR [552] Failure during SQL operation to the database : ORA-01722: invalid number.
I don't understand how manipulate this field because in the form it appears like an italian date (20/05/2004 10.23.44) meanwhile in the database table it's a numeric field.
Can you help me to solve this problem????
Thanks a lot in advance.
Bye.
Leonardo.
I've got a problem!
I have a form on which there's a date/time field. and a button. When I press the button fires an active link and it execute a direct sql action making an update on database.
The command is:
Update LEOFRA_STORICO_TRANS
set DATA_CESSAZIONE= $Data Appo$
where IDTT=$IDTT$ and ORDINE_TRANS=(($Ordine Trans$)-1).
Now, everytime I press the button there is an error:
ERR [552] Failure during SQL operation to the database : ORA-01722: invalid number.
I don't understand how manipulate this field because in the form it appears like an italian date (20/05/2004 10.23.44) meanwhile in the database table it's a numeric field.
Can you help me to solve this problem????
Thanks a lot in advance.
Bye.
Leonardo.
RE: Using date/time field in direct sql command
in the form you can see the italian date format, but in database the date fields are stored as a number (seconds since 01/01/1970). So if you want to update this date using SQL you need convert the date.
If you use SQL Server, the sentence could be something like:
Update LEOFRA_STORICO_TRANS
set DATA_CESSAZIONE= datediff(ss,'01/01/1970 00:00:00',$Data Appo$)
where IDTT=$IDTT$ and ORDINE_TRANS=(($Ordine Trans$)-1).
This is for a GMT +00 location. If you are in a GMT+01 location you need use 01:00:00 in the datediff function.
Hope this helps;
Jose Manuel Viejo Lobato
josemanuel@viejolobato.com
http://ars.viejolobato.com