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

Similar Messages

  • Boss is gonna kill me. I Need help inserting a DATE/TIME into MSAccess

    Hello,
    I have spent way to long trying to figure out how to insert a date into the date/time field of a microsoft access database. Could someone please help me figure this out. I know there are a million previous posts about this topic and i looked through a bunch and none of them seem to work... i have tried so many different things. The code i am working (at this point in time.. since it has changed a million times) is:
                             String MYDATE = "yyyy-MM-dd hh:mm:ss a";
                             Date date = new Date();
                             String dateout = new SimpleDateFormat(MYDATE).format(date);
                             System.out.println(" the date is " + dateout);
    Timestamp timeStamp = new Timestamp(date.getTime());
    timeStamp.setNanos(0);
                             System.out.println(" the date is " + timeStamp);
                             String sql2 = "INSERT INTO DATE5 (stuff, date) VALUES ('hello', CVDATE(" + timeStamp + "))";
                             ProblemTrackingDB.DoUpdate(sql2);
                             sql2 = "INSERT INTO DATE5 (stuff, date) VALUES ('hello', '" + dateout + "')";
                             ProblemTrackingDB.DoUpdate(sql2);
    i have tried both of those ways and either work (ie... comment one out and try the other)
    i always get a " Syntax error in INSERT INTO statement" thrown
    i have also tried without the single quotes.
    Any help would Be MUCH appreciated as my boss is starting to get agrivated...
    thanks to anyone who helps,
    Jon

    Change your program to use a PreparedStatement to do this insert. You only need to create a PreparedStatement once, so in your constructor or initializer do this:PreparedStatement insert = connection.PrepareStatement("INSERT INTO DATE5 (stuff, date) VALUES (?, ?)");Then the code to write a record is this:Timestamp timeStamp = new Timestamp(date.getTime());
    timeStamp.setNanos(0);
    insert.setString(1, "hello");
    insert.setTimeStamp(2, timeStamp);
    insert.executeUpdate();That's all. You never need to mess about with formatting timestamps in the way your database needs them, the PreparedStatement takes care of all that for you.

  • 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

  • Inserting a associative array into a table

    Hi,
    I am working on a process where I want to store the temporary results in an associative array. At the end of the process I plan to write the contents of the array into a table that has the same structure. (the array is defined as a %rowtype of the table)
    Is it possible to execute ONE sql statement that transfers the array into the table? I am on 10g (10.2.0.4.0)
    Here's what I have now:
    declare
      type t_emp is table of emp%rowtype index by pls_integer;
      v_emp t_emp;
    begin
      -- a process that fills v_emp with lots of data
      for i in v_emp.first .. v_emp.last
      loop
        insert into emp values v_emp(i);
      end loop;  
    end;But it would be better if the loop could be replaced by sql one statement that inserts all of v_emp into emp. Is that possible?
    Thanks!
    PS: I'm not sure whether it's a good idea to use this approach... building a table in memory and inserting it into the database at the end of the process. Maybe it's better to insert every record directly into the table... but in any case I'm curious to see if it is possible in theory :)
    Edited: Added version info

    True, SQL cannot access the PL/SQL type.
    So you can not do something like this:
    insert into emp
    select * from table(v_emp)That is not possible.
    But FORALL is possible:
    FORALL i in v_emp.first .. v_emp.last
        insert into emp values v_emp(i);FORALL makes just one "round trip" to SQL bulk binding the entire contents of the array.
    It is much more efficient than the normal FOR loop, though it is mostly a PL/SQL optimization - even the FORALL actually inserts the rows "one at the time", it just hands the entire array to the SQL engine in one go.
    If the logic has to be done procedurally, FORALL is efficient.
    If the logic can be changed so arrays can be avoided completely and everything done in a single "insert into ... select ..." statement, that is the most efficient.

  • How CallableStatement in JSP use setDate() method to insert the date value into DB?

    Dear all,
    I met a strange error message when i insert a date value into DB via JSP call PL/SQL procedures.
    The error seems caused by the setDate(index, date) method with CallableStatement.
    The message is: Can not find the setDate(int, java.util.Date) method in the CallableStatement interfaces.
    Any ideas?
    Thanks advanced.

    Thank you!:)
    I solved it using this:
    String name="david";
                stmt = con1.createStatement();
                String prikaz1 = "INSERT INTO table (id,age,surname,name) IN 'C:\\Users\\David\\Desktop\\db.mdb' SELECT id,age,surname,' " + name + " ' FROM table2";
                stmt.executeUpdate(prikaz1);

  • Best way to insert millions of records into the table

    Hi,
    Performance point of view, I am looking for the suggestion to choose best way to insert millions of records into the table.
    Also guide me How to implement in easier way to make better performance.
    Thanks,
    Orahar.

    Orahar wrote:
    Its Distributed data. No. of clients and N no. of Transaction data fetching from the database based on the different conditions and insert into another transaction table which is like batch process.Sounds contradictory.
    If the source data is already in the database, it is centralised.
    In that case you ideally do not want the overhead of shipping that data to a client, the client processing it, and the client shipping the results back to the database to be stored (inserted).
    It is must faster and more scalable for the client to instruct the database (via a stored proc or package) what to do, and that code (running on the database) to process the data.
    For a stored proc, the same principle applies. It is faster for it to instruct the SQL engine what to do (via an INSERT..SELECT statement), then pulling the data from the SQL engine using a cursor fetch loop, and then pushing that data again to the SQL engine using an insert statement.
    An INSERT..SELECT can also be done as a direct path insert. This introduces some limitations, but is faster than a normal insert.
    If the data processing is too complex for an INSERT..SELECT, then pulling the data into PL/SQL, processing it there, and pushing it back into the database is the next best option. This should be done using bulk processing though in order to optimise the data transfer process between the PL/SQL and SQL engines.
    Other performance considerations are the constraints on the insert table, the triggers, the indexes and so on. Make sure that data integrity is guaranteed (e.g. via PKs and FKs), and optimal (e.g. FKs should be indexes on the referenced table). Using triggers - well, that may not be the best approach (like for exampling using a trigger to assign a sequence value when it can be faster done in the insert SQL itself). Personally, I avoid using triggers - I rather have that code residing in a PL/SQL API for manipulating data in that table.
    The type of table also plays a role. Make sure that the decision about the table structure, hashed, indexed, partitioned, etc, is the optimal one for the data structure that is to reside in that table.

  • How to insert a gif file into a table?

    Hi,
    I need to insert a gif file into a table. Can anyone tell me where I can find the information on how to create this kind of table, how to insert a gif file into a table and how to select?
    Thanks,
    Helen

    Hi Helen,
    You could read about that in the documentation which is available online.
    For a starter: BLOB. And I bet there are many examples to be found on the web.
    Good luck. :)
    Regards,
    Guido

  • Possible to insert a countdown timer into an iMovie clip?

    I'm making an exercise video, and I want to insert an occasional small clip with a countdown timer.  Ideally, it would be some beautiful nature footage (like waterfalls or wildlife), with a countdown timer in the corner.
    Does anydbody know how to insert a countdown timer into an iMovie clip?
    For that matter, does anybody know where I could find/purchase 2 minutes of nature footage?

    Sure you can. What you need to do is add the initial image to the topic then create an image map. This allows you to define shapes that when the user's mouse hovers over it indicates that there is a hyperlinkto another topic. Just right click on the image, select Insert Image Map and go from there.
      The RoboColum(n)
      @robocolumn
      Colum McAndrew

  • 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

  • How could I insert the deleted row into another table within a trigger?

    Hi,
    How could I insert the deleted row into another table within a trigger? The destination table has the same columns as the source table. Since the statements are in the trigger, it is not allowed to query the source table named 'test'. Thanks! The trigger is as follows, uncompleted:
    CREATE TRIGGER delete_trigger
    AFTER DELETE
    ON test
    FOR EACH ROW
    BEGIN
    -- How could I insert the deleted row into another table
    END delete_trigger;
    Message was edited by:
    user569548

    Hi,
    I'm not sure what's wrong there.
    I read the oracle docs about ANALYZE and ALL_TAB_COLUMNS, and did the following:
    ANALYZE TABLE my_tab VALIDATE STRUCTURE; //went ok.
    SELECT column_name
    FROM all_tab_columns
    WHERE table_name = 'my_tab'; //but no rows selected?
    This topic might not be what this thread should be about. Here I posted a new thread:
    How to get colum names of the newly created table?
    Thanks.
    Message was edited by:
    user569548

  • How to paste tabbed data directly into FM7 table cells?

    <<<<on edit.... changed FM8 to FM7... I have FM7, not FM8>>>
    Hello
    I'm working on a documentation job that requires a pasting external data into existing table cells in FM7.
    I have tried several things but I can't find a way to paste the data directly into the table cells.  The source data can be delimited text, or spreadsheet cells. Neither can be pasted into an existing table.   The only way I can make this work is to first paste it into FM as text, then convert it to another table, and then copy/paste from that table into the existing one.  This is a lot of extra work and it seems there should be a way to paste external data directly across table cells.   I also tried "paste special" but that is not an option when I have table cells selected.
    Any ideas???
    It would be much appreciated!
    Thanks
    Gary Beckwith

    Gary, just had a thought -- I've worked on several projects where I used variables in tables that might work better for you.
    Basically the idea is to pre-populate the tables in your chapter with variables in the cells, and then import a minimalist MIF file that only contains the variable definitions for the pre-existing variables.  The minimalist MIF file can be made quite easily from a database or from an Excel CSV or TSV export by using various scripting utilities to convert comma-delimited text into the MIF syntax.
    I've created chapters that had hundreds of thousands of cells with variables in them, and updating the variables is incredibly quick.
    The best way to approach the variable naming is to come up with a convention that is easy to apply, I found .r1c1 etc to be a good starting point (the period so that the variables all sort in the same place in FM, the lower-case letters to make the variable's name as horizontally short as possible.

  • Insert current date/time and username into form.

    Apologies for newbie question.
    I have a form based on table Customer, within the table I have username and modifiedDate columns. How can I populate these text fields with the current user and current date/time ?
    Thanks.

    Excellent, thanks for the fast response. I had this working and then tried in on a new form and now it fails to populate the desired fields.
    I have created a process named "Insert date and username", Type P/SQL anonymous block. On Load - After Header, Once Per Page Visit.
    select :APP_USER, to_char(SYSDATE,'DD-MON-YYYY HH24:MI:SS')
    INTO :P16_USERNAME, :P16_MODIFIEDDATE
    from dual;
    Sorry for the hand holding!
    Jason
    Edited by: Jason S (UK) on Apr 24, 2013 6:57 AM

  • 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!

  • 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

  • How to insert this date colum into some other table

    Hi all,
    I have to write a procedure to select the data from one table & insert date column data into another table,the data is in different date formats,but in the second table date column format should be (mm/dd/yyyy) .
    example:
    if the date in first table is 1992 it should be modify to "01-01-1992" & insert into the second table.But the values should be different(below are the different types).
    RELEASE_DATE
    1992
    1962
    July 1987
    Aug 1968
    10/30/06
    6/1/2005
    2004
    7.25.1951
    12/12/2006
    12/1/2005
    1992
    2003
    2005
    1958
    2002
    11/11/03
    1/1/91
    50-21-2001
    10.28.1991
    Please any body can help.

    <FONT FACE="Arial" size=2 color="2D0000">
    Thanks..! for giving the data type..
    Here is an example..
    SQL> desc atestdate
    Name                                      Null?    Type
    CHARDATE                                           VARCHAR2(10)
    ACTDATE                                            DATE
    SQL> select * from atestdate;
    1992
    July 1987
    Aug 1968
    10/30/06
    6/1/2005
    2004
    7.25.1951
    12/12/2006
    12/1/2005
    1992
    2003
    2005
    1958
    2002
    11/11/03
    1/1/91
    50-21-2001
    10.28.1991
    18 rows selected.
    SQL> select <font color="#0000ff">char_trim_x</font>(chardate) from atestdate;
    1992
    July-1987
    Aug-1968
    10-30-06
    6-1-2005
    2004
    7-25-1951
    12-12-2006
    12-1-2005
    1992
    2003
    2005
    1958
    2002
    11-11-03
    1-1-91
    50-21-2001<font color="#8000ff">--? 50 can not be a month nor a date  do not give  junk values</font>
    10-28-1991
    18 rows selected.
    <font color="#0000ff">char_trim_x</font> This is a function which I have created with REPLACE function
    this brings to some extent of an orderly format..
    <font color="#008000">But you have not yet posted your work ..</font>
    -SK
    </FONT>

Maybe you are looking for

  • ADF Unable to filter / sort date column in table

    Hi, I am using JDeveloper 11.1.1.7. I have a read only table inside a panel collection. One of the columns in the table is a date field. I have filterable and sortable properties set to true for all columns. Filter and sort property works for all col

  • Unable to update iPhoto in Mac AppStore

    Hi guys, I'm stuck with updating iPhoto 9.1.5 to 9.2.1. I called with Apple because of this matter but they couldn't help me out. I bought my iMac last year and from the beginning it's saying there is an update for iPhoto. But when I try to update wi

  • Why do I only get 2 pages when export PDF to Word?

    I have a PDF document that was created from Word (probably 2003). I was asked to convert this document back to Word. When I do this, the progress bar shows that it's converting all 16 pages, but when I open the file in Word, I only have the first 2 p

  • Variable for FISCPER in Infopackage

    Hello gurus; Currently I have 3 infopackages that uploads data according with the year: - Last Year - Current Year - Next Year It's a full extraction. In the Data Selection tab, we have the FISCPER (Fiscal year / period). At the present moment there

  • Copy and paste gives incorrect number of signs in chatroom of community site

    I write tekst in Word 2007 for about 700 signs. Select and copy, go to chatroom and paste. Error and tells there are 14835 signs, to large. I open Google Chrome and paste only (2th time), no problem. Go back, delete message and paste only (3th). Now