Click to See Complete Forum and Search --> : insert date and time


jrthor2
05-28-2003, 07:41 AM
I have a form where ther person is to enter a date and a time. The date is entering fine, but there is no time. How do I enter the time into the date column? Below is my code:

$sqlstmt="INSERT INTO sysadm.inqad_deployment (ENT_DTE, COMMENTS, LST_MNT_OPR_ID, LST_MAINT_TSMP )
values (to_date('$ent_dte $time', 'MM-DD-YYYY HH24:MI'), :comments, :session_userid, sysdate)";
$sqlstmt_arg = "comments" . DELIM . $comments . DELIM .
"session_userid" . DELIM . $session_userid;

pyro
05-28-2003, 07:52 AM
Is that an Oracle database? If so, I don't know how the to_date function works, so I can't really help you... I could take a few shots in the dark, but...

jrthor2
05-28-2003, 07:54 AM
Yes, it is an oracle database

pyro
05-28-2003, 08:02 AM
Ok, here is a guess, if you want it...

the PHP date in to_date(), is more than likely suppose to all be in one variable. Here is the only example I was able to find...

the PHP:
$current_time=date("YmdHis"); # date will be in this format: YYYYMMDDHH24MMSS

and the to_date() from the query:
TO_DATE('$current_time','YYYYMMDDHH24MISS')

jrthor2
05-28-2003, 08:05 AM
but my date and time are coming from a form that ther person fills out??

pyro
05-28-2003, 08:09 AM
Concatenate them...

$current_time = $ent_dte.$time;

Also, tell me you are not using global variables...

jrthor2
05-28-2003, 08:13 AM
Well, it is entering the date still, but no time. Here is my code:

$current_time = $ent_dte.$time;

$sqlstmt="INSERT INTO sysadm.inqad_deployment (ENT_DTE, COMMENTS, LST_MNT_OPR_ID, LST_MAINT_TSMP )
values (to_date('$current_time', 'MM-DD-YYYYHH24:MI'), :comments, :userid, sysdate)";
$sqlstmt_arg = "comments" . DELIM . $comments . DELIM .
"userid" . DELIM . $userid;

$D= new mydb;
$D->my_sqlbnd($sqlstmt, $sqlstmt_arg);

jrthor2
05-28-2003, 08:15 AM
Never mind, it is working, I just forgot to add the HH24:MI when displaying the date.

Thanks for your help.