www.webdeveloper.com
Results 1 to 8 of 8

Thread: insert date and time

  1. #1
    Join Date
    Jan 2003
    Location
    PA
    Posts
    1,898

    insert date and time

    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;

  2. #2
    Join Date
    Dec 2002
    Location
    High on life
    Posts
    10,104
    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...

    Personal website http://www.ryanbrill.com/
    Business website: http://www.infinitywebdesign.com/
    TypeSpace http://www.typespace.org/

    I reject your reality and substitute it with my own!

  3. #3
    Join Date
    Jan 2003
    Location
    PA
    Posts
    1,898
    Yes, it is an oracle database

  4. #4
    Join Date
    Dec 2002
    Location
    High on life
    Posts
    10,104
    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')

    Personal website http://www.ryanbrill.com/
    Business website: http://www.infinitywebdesign.com/
    TypeSpace http://www.typespace.org/

    I reject your reality and substitute it with my own!

  5. #5
    Join Date
    Jan 2003
    Location
    PA
    Posts
    1,898
    but my date and time are coming from a form that ther person fills out??

  6. #6
    Join Date
    Dec 2002
    Location
    High on life
    Posts
    10,104
    Concatenate them...

    PHP Code:
    $current_time $ent_dte.$time
    Also, tell me you are not using global variables...

    Personal website http://www.ryanbrill.com/
    Business website: http://www.infinitywebdesign.com/
    TypeSpace http://www.typespace.org/

    I reject your reality and substitute it with my own!

  7. #7
    Join Date
    Jan 2003
    Location
    PA
    Posts
    1,898
    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);

  8. #8
    Join Date
    Jan 2003
    Location
    PA
    Posts
    1,898
    Never mind, it is working, I just forgot to add the HH24:MI when displaying the date.

    Thanks for your help.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles