Link to home
Start Free TrialLog in
Avatar of excii
excii

asked on

Inserting date to oracle db with php ***URGENT, HELP ME****

Hi!

I have oracle8 db. When I select and print the date to html page date's format is 2002-05-24 00:00:00

Now I am trying to insert date to oracle db with INSERT INTO. Which format I should insert that date?
I have tried these SQL commands:

<?php
$connect = odbc_connect("db_name", "user", "pass") or die ("Can't connect");

$query = "INSERT INTO TABLE (DATE) VALUES ('09.06.2003')";

$result = odbc_exec($connect, $query);

odbc_close($connect);
?>

And I have tried these also:
$query = "INSERT INTO TABLE (DIARY_DATE) VALUES ('2002-06-09 00:00:00')";
$query = "INSERT INTO TABLE (DIARY_DATE) VALUES ('09.06.2003')";

I always get these errors:
SQL error: [Oracle][ODBC][Ora]ORA-01861: literal does not match format string
SQL error: [Oracle][ODBC][Ora]ORA-01843: not a valid month



Regards,

Exc
ASKER CERTIFIED SOLUTION
Avatar of Giovanni G
Giovanni G
Flag of Italy image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of excii
excii

ASKER

example was DATE, real field name is DIARY_DATE
Avatar of excii

ASKER

hmm... How can I see databases field types?
Could I do it with some SQL sentence with php or something?
Avatar of excii

ASKER

I think I should use someting like TODATE function or am I wrong?

Something like this:

$query = "INSERT INTO DIARY (DIARY_TYPE,DIARY_DATE) VALUES (1,todate('09.06.2003', 'dd.mm.yyyy'))";

But that won't work because I don't know how to use ToDate function right....

help?

hmm 06/09..
it seems i lost this thread :-) sometimes a "still there?" helps
do you still need help with it?