×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Using date/time field in direct sql command

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.

RE: Using date/time field in direct sql command

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
http://ars.viejolobato.com

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close