Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using date/time field in direct sql command

Status
Not open for further replies.

leomar

Programmer
Feb 14, 2005
3
IT
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.
 
hello;

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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top