Results 1 to 2 of 2
  1. #1
    Java Tip's Avatar
    Java Tip is offline Moderator
    Join Date
    Nov 2007
    Posts
    1,694
    Blog Entries
    430
    Rep Power
    9

    Default Getting current date using dual (Oracle)

    The code snippet prenseted below shows the use of dual when fetching dates from Oracle.

    Java Code:
    String sql =
      "select {fn dayname ({fn now()})}," +
      "           {d '1997-05-24'}, " +
      "           {t '10:30:29' }, " +
      "           {ts '1997-05-24 10:30:29.123'}" +
      "           from dual" ;
    
    ResultSet rs = stmt.executeQuery(sql);
    
    while (rs.next())
       System.out.println("results: " + rs.getString(1) +
          "\n "   + rs.getString(2) +
          "\n "   + rs.getString(3) +
          "\n "   + rs.getString(4) );

  2. #2
    Join Date
    Feb 2008
    Posts
    2
    Rep Power
    0

    Default

    Why not just do:

    select sysdate from dual;

    then do

    rs.getDate or rs.getTimeStamp.

Similar Threads

  1. Difference between current date and anothe date
    By vijay balusamy in forum New To Java
    Replies: 1
    Last Post: 04-16-2008, 04:15 PM
  2. Inserting current date into a DB table
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 02-15-2008, 08:38 AM
  3. how to get the current date and time
    By valery in forum New To Java
    Replies: 1
    Last Post: 08-03-2007, 06:05 PM
  4. Compatibility with Dual Core Procesors
    By dlgoes in forum Advanced Java
    Replies: 1
    Last Post: 05-24-2007, 10:17 PM
  5. oracle query with date question
    By orchid in forum JDBC
    Replies: 1
    Last Post: 05-09-2007, 12:10 AM

Posting Permissions

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