Insert statement with Date, time into Oracle

Hi,
I've got the following statement that I'm trying to insert into Oracle. Actually had to change up the format to dd-mm-yy to get it to insert the date correctly, not sure why, but I've got it "supposedly" formatted to also insert the hours, min., seconds into the db record, but it's not catching it.
My code:
INSERT INTO VOTETBL
(CHANGE_CTRL_ID,BUSVP,BRANCH,VOTE,VOTE_TIMESTAMP)
VALUES (?, ?,?,?,to_date(sysdate, 'dd-mm-yy hh24:mi:ss'));Shouldn't the sysdate capture all those elements sufficiently? The day, month, year get inserted correctly with this, but not so for the time portion.
Any suggestions is welcomed.
Thx.

ok, thanks.
I tried making a result set with the following:
Statement stmt = connection.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY);
ResultSet rst = stmt.executeQuery("select to_char(sysdate) from dual");
Date dualtimestamp = (rst.getDate("sysdate"));But it makes the servlet blow up! Not sure why either, because if I enter that exact statement in Oracle, it pulls back the date and time just like I aim to. But not embedded in the result set statement within the servlet.
It breaks up somehow and doesn't get that result!

Similar Messages

  • Insert date time into oracle database from jsp

    pls tell me ,from jsp how can I insert datetime values into oracle database .I am using oracle 9i .here is codethat i have tried
    html--code
    <select name="date">
    <option selected>dd</option>
    <option>1</option>
    <option>2</option>
    <option>3</option>
    <option>4</option>
    </select>
    <select name="month">
    <option selected>dd</option>
    <option>1</option>
    <option>2</option>
    <option>3</option>
    <option>4</option>
    </select>
    <select name="year">
    <option selected>dd</option>
    <option>2004</option>
    <option>2005</option>
    <option>2006</option>
    <option>2007</option>
    </select>
    here the jsp code
    <% date= request.getParameter("date"); %>
    <% month= request.getParameter("month"); %>
    <% year= request.getParameter("year"); %>
    try
    { Class.forName("oracle.jdbc.driver.OracleDriver"); }
    catch (ClassNotFoundException exception)
    try
         Connection connection = null;
         out.println("connectiong the database");
    connection = DriverManager.getConnection("jdbc:oracle:thin:@127.0.0.1:1521:orcsid","scott","tiger");
    out.println("connection getted");
         int rows = 0;
         String query_2 = "insert into mrdetails values(?)";
         String dob = date+month+year;
         prepstat = connection.prepareStatement(query_2);
         prepstat.setTimestamp(4,dob);
         rows = prepstat.executeUpdate();
         out.println("data updated");
    catch (Exception exception3)
    out.println("Exception raised"+exception3.toString());
    }

    To insert date values into a database, you should use java.sql.Date. If it also has a time component, then java.sql.TimeStamp.
    Your use of prepared statements is good.
    You just need to convert the parameters into a date.
    One way to do this is using java.text.SimpleDateFormat.
    int rows = 0;
    String query_2 = "insert into mrdetails values(?)";
    String dob = date+"/" + month+ "/" + year;
    SimpleDateFormat sdf = new SImpleDateFormat("dd/MM/yyyy");
    java.util.Date javaDate = sdf.parse(dob);
    java.sql.Date sqlDate = new java.sql.Date(javaDate .getTime);
    prepstat = connection.prepareStatement(query_2);
    prepstat.setTimestamp(4,sqlDate);
    rows = prepstat.executeUpdate();
    out.println("data updated");Cheers,
    evnafets

  • Inserting and updating date & time in oracle 8i

    I am using JDBC thin driver. I am not able to insert date and time in American format.

    The best way for you is to use the TO_DATE function. It will allow you to specify the date format.

  • Inserting logon date & time into a table

    hi,
    i want to insert the logon date&time into a table which have a field
    called log_track and data type as date. i want to insert the
    information as 'dd/mm/yyyy hh24:mi:ss' . I tried to insert with
    the follwoing
    insert into log_chek values ( to_date(sysdate,'dd/mm/yyyy hh24:mi:ss))
    but it is not taking the time...how to include the time also..? I am using oracle 8i
    thanks in adv
    kris

    Dates are stored as dates. You cannot select to store a date in date format like dd/mm/yyyy hh24:mi:ss. That is not your decision to make. It is stored as a date format as a binary value.
    How you want to view that date, is your decision. How must this binary date format value much be displayed as a text string?
    So, when inserting a date you insert it as a date. That simple.
    insert into log_chek values ( sysdate )
    When you want to view that date, you decide how you would like it to be displayed in human readable format:
    select TO_CHAR( log_date, 'dd/mm/yyyy hh24:mi:ss') as log_date from log_chek

  • Need Help Urgently - Want to Load Time Data Automatically into Oracle HRMS

    Hi All,
    I am on my 1st Oracle HRMS project and I need urgent help on HOW TO load Time (IN/OUT) Data from a MS Access database which is populated by a Biometric Hand Geometry System.
    And we need to do it in real time as the data inserted in the MS Access Database we need to pull that into Oracle HRMS for Payroll purposes.
    If somebody can help me in this I'll greatly appreciate that.
    Thanks, AGAIN IT IS VERY URGENT
    Zee

    Zee,
    Let's go back to your core requirement "load Time (IN/OUT) Data from a MS Access database which is populated by a Biometric Hand Geometry System".
    Questions:
    1. Is this time data to be used to pay a person through Oracle Payroll?
    2. What legislation (country) is this for?
    3. Are you using Oracle Time and Labor (OTL) as the front-end or do you intend to enter the data directly into Oracle Payroll?
    See the following OTL documents:
    MetaLink Note 369022.1 - How Can Hours Worked Be Imported into OTL From Third Party System?
    MetaLink Note 223987.1 - Oracle OTL HXC TimeStore Deposit API
    MetaLink Note 283593.1 - Formatting an Exported Timecard Template using Microsoft Excel
    Regards,
    Greg

  • Insert a value of type Date/Time into a database

    I am trying to insert a value of type date time into an access database. What is the format needed to insert the date/time.
    Thanks,
    -Amos

    I had all kinds of problems getting a datetime inserted into a SQl Server DB. Probably similar so this is what I do:
    String date = new String("01/01/97 12:00:00");
    stmt.setObject(1, date);
    I tried using TimeStamp's but found I got an occasional Fractional Truncation exception back from the driver. Never had a problem inserting a String using the setObject() method though.
    Hope this helps

  • With 10.7.2 update iCal does not allow you to set "Reminders" by draging events from "All Day Events" into "Reminders" is there another way to do this instead of having to type out the entire reminder with date, time, and type?

    With 10.7.2 update iCal does not allow you to set "Reminders" by draging events from "All Day Events" into "Reminders" is there another way to do this instead of having to type out the entire reminder with date, time, and type?
    With Lion 10.7.1. you where able to drag events from "All Day Events" into the "Reminders" bar to create upcoming reminders.

    Exactly the same question I was about to post!
    Great being able to sync reminders (well overdue) however if I have to re-type a calener envent into reminders it's a waste of time!! 
    Come on Apple!!
    Just need an option for the calender event to add to reminder or the old drag to add to reminder functionality back, Please???

  • In Pages, how to insert a PRINT-DATE field into a doc.?

    Want to insert a field that will show the date of the doc's printing. 
    In MS Word, this is known as 'insert print date'.
    How to do so in Pages?  Thanks.

    You can define placeholder text in Pages v5.5.2 in any of the six header/footer sections. Think of it as a a field code that when you click on it the text you enter replaces the placeholder text using the same style. By example, I placed a combination of text and placeholder text in the lower left footer segment.
    The text and the brackets were selected, and then Format ▸ Advanced ▸ Define as Placeholder Text. Also, because it is in the footer, it is replicated throughout the document. Although you could Insert > Date/Time into this placeholder text, automation may be preferred. I have chosen to use the same date/time style as MS Word uses in its print date field code. You can only change placeholder text programmatically with Pages and AppleScript on Yosemite. Once I run the AppleScript, all placeholder tags are replaced as shown in this image:
    You could make this an Automator Service (e.g. run AppleScript action with no input, and output replacement is checked). One could assign a keyboard shortcut to this service too. One click printed date stamp and document sent to default printer.
    The AppleScript (Yosemite only).
    property tagStr : "[print-date]"
    --- used for testing ---
    -- set f to POSIX path of ((path to desktop) as text) & "arg.pages"
    -- set hf to POSIX file f as alias
    set printDate to "" as text
    set theTags to {}
    tell application "Pages"
          activate
          -- open hf
          tell front document
               set theTags to the tag of every placeholder text whose tag is equal to tagStr
               -- Word print-date field code uses this 12-hour date/time format as mm/dd/YY 00:00 AM/PM
               set printDate to do shell script ("/bin/date +'%D %l:%M %p'") as text
               repeat with i from 1 to count of theseTags
                     set thisTag to item i of theseTags
                     set (every placeholder text whose tag is thisTag) to printDate
               end repeat
               -- use your own System Preferences printer name string
               tell application "Samsung ML-2950 Series (Sammy)"
               activate
               -- no print dialog
                    print front document without «class pdlg»
                    quit
               end tell
          end tell
          -- close front document saving no
    end tell

  • Problem with date format from Oracle DB

    Hi,
    I am facing a problem with date fields from Oracle DB sources. The date format of the field in DB table is 'Date base type is DATE and DDIC type is DATS'.
    I mapped the date fields to Date characters in BI. Now the data that comes to PSA is in weird format. It shows like -0.PR.09-A
    I have changing the field settings in DataSource  to internal and external and also i have tried mapping these date fields to text fields with out luck. All delivers the same format.
    I have also tried using conversion routines like, CONVERSION_EXIT_IDATE_INPUT to change format. It also delivers me the same old result.
    If anybody of you have any suggestions or if anybody have you experienced such probelms, Please share your experience with me.
    Thanks in advance.
    Regards
    Varada

    Thanks for all your reply. I can only the solutions creating view in database. I want some solution to be done in BI. I appreciate if some of you have idea in it.
    The issue again in detail
    I am facing an issue with date fields from oracle data. The data that is sent from Oracle is in the format is -0.AR.04-M. I am able to convert this date in BI with conversion routine in BI into format 04-MAR-0.
    The problem is,  I am getting data of length 10 (Output format) in the format -0.AR.04-M where the month is not in numericals. Since it is in text it is taking one character spacing more.
    I have tried in different ways to convert and increased the length in BI, the result is same. I am wondering if we can change the date format in database.
    I am in puzzle with the this date format. I have checked other Oracle DB connections data for date fields in BI, they get data in the format 20.081.031 which will allow to convert this in BI. Only from the system i am trying creating a problem.
    Regards
    Varada

  • INSERT statement with JSP

              Does anyone know how to create an INSERT statement with JSP using
              variables??
              I can do the insert if I code the values of the variables in the statement,
              but when I try to use variables to do the insert it tries to insert the
              variable name and not the value of the variable into the table.
              Thanks,
              Doug
              

    "Doug Schaible" <[email protected]> wrote in message news:<bicO7.1279268$[email protected]>...
              > I can do the insert if I code the values of the variables in the statement,
              > but when I try to use variables to do the insert it tries to insert the
              > variable name and not the value of the variable into the table.
              Doug,
              I think you missed the <%= blahblah %> syntax.
              Regards
              drit
              

  • Is 000001010000z a valid date time in Oracle?

    Hi,
    When working with Open LDAP connection from Oracle, I need to set and remove the value '000001010000z' for locking and unlocking the user account respectively. This is working fine. However, for some calculation, I need to convert this value as a date value which I couldn't do. Is this a valid date time in Oracle? If so how to convert it as a date value.
    Oracle version: 10g R2
    Thanks,
    Natarajan

    Thanks, Mithun for your answer. We have the same issue, as an user, we can lock an account using the special value, but unable to unlock using the same user. I have reported this to our LDAP administrator.
    Regarding my question using this special value as a date value in oracle, though it is a valid date in the LDAP system, we cannot convert this as a date value in Oracle.
    Natarajan

  • How to copy Log text (with Date, Time stamp ) User IDfrom BP to Transaction

    Hi Experts,
                     Can someone guide us how  to copy Log text (with Date ,Time & User ID) fron Business partner  (Prospect) to transactions by text detrmination procedure.
    Regards,
    Basavaraj Patil

    save text
    Fill out following parameters of SAVE_TEXT function module:
    HEADER
    TDOBJECT C 10 BUT000
    TDNAME C 70 10 digit BP number
    TDID C 4 Z001
    TDSPRAS C 1 Language
    INSERT = ’X’
    LINES
    TDFORMAT TDLINE
    |
    |testtttttttttttttttttttttttt( Your text)
    I would suggest you to use some other BAPI that would attach your text to BP than SAVE_TEXT.
    If you still wanted to use SAVE_TEXT then first make sure how the TDNAME is generated. It depends on the text determination procedure. For examples, it can be guid of BP, GUID followed by date or time or else the BP number itself.
    Just go to BP transaction, double click on the text pad, it will open you the SAP Script editor. Click on menu GOTO and select Header which will give you info about your TDID, TDOBJECT, TDNAME....
    Hope this helps.

  • FUNCTION MODULE TO CONVERT DATE / TIME INTO WORDS.

    HI EXPERTS,
         FUNCTION MODULE TO CONVERT DATE / TIME INTO WORDS.
    PLS DO HELP.....

    Hiii gita
    we have another FM SPELL_AMOUNT
    regards
    Jaipal

  • Output triggred in the invoice with Date/Time 1

    Output triggred in the invoice with Date/Time as 1 i e Send with periodically scheduled job.
    So could you  let me know when this gets triggeed if we maintain 1 in condition record?
    Thanks,
    Praveen

    Hi Praveen,
    When you maintain 1in the Date/Time column in the Condition Records for O/P of say the Invoice it means that you are telling the system to send the O/P with periodically scheduled job.
    To achieve this you must use the report program RSNAST00.The message is processed through report program RSNAST00. This report program can be scheduled periodically or started manually.
    For scheduling periodically you need to set up a batch process in SM35.
    Hope this helps,
    J Nagesh

  • Insert current date and time into Oracle date type field

    I have a JDBC current date and time insert into Oracle 9i that almost works. It submits the current date and a fixed time into the Oracle date type field. I am using Tomcat 6.0.20.
    For example if I insert the data at 7:24:04 PM on Feb 16, 2010 it will insert as: 16-Feb-2010 12:00:00 AM
    The date part works but the time always shows 12:00:00 AM no matter what date or time the data is inserted.
    Here is what I have for my JDBC inserts and I also tried something with DateFormat:
    PreparedStatement ps; Date mydate = new Date(new java.util.Date().getTime()); //insert statement here.... stmt.setDate(1,mydate);
    I also tried:
    PreparedStatement ps; java.sql.Timestamp mydate = new java.sql.Timestamp(new java.util.Date().getTime()); SimpleDateFormat fmt = new SimpleDateFormat(.... //insert statement here.... ps.setTimestamp(1,fmt.format(mydate));
    Both keep submitting the date into Oracle as 16-Feb-2010 12:00:00 AM
    Anyway to get the current date and time? For example if I insert the data at 7:24.04 pm today it should show as 16-Feb-2010 07:24.04 PM in Oracle.

    sportsMarkr wrote:
    Date mydate = new Date(new java.util.Date().getTime());Please see the javadocs for java.sql.Date and note the part that says "...to zero"
    [http://java.sun.com/javase/6/docs/api/java/sql/Date.html]
    If you want a date and time then use java.sql.Timestamp.

Maybe you are looking for

  • Lion 10.7.4 -iphoto, safari and mail won't open

    I just bought four iMacs for my school. Two of them won't open the mail, iphoto or safari. I have spent quite a bit of time with the Apple rep, but at this point, he has run out of ideas. I have reinstalled Lion - not a clean install, but hate the th

  • PCI Implementation

    Hi, Can u please guide me the how to setup Payment Card Industry.What are the security products are required and how to implement those products . Waiting for your reply. Regards Sivaji.P

  • Insert Image broken

    The Insert Image button (the camera icon) is greyed out and doesn't work. So much for screenshots, which are very helpful in explaining and troubleshooting.

  • Text jumping when scrolling

    I use Gurmikhi font to display some Gurmukhi text in my JTextPane. But when I scroll the text, some of the letters are made bigger than they are and the font semms to be jumping. How can I render the text properly? Help me, please. Without scrolling

  • Garage band issues.

    I'm using garage band and i accidentally press something on my keyboard to make the sound stop playing, while all of the volume is up and on a setting. is their some type of mute that its on i can't figure it out?