File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and Relational Databases and the fly likes JDBC - Date Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Barcodes with iOS this week in the iOS forum
or Core Java for the Impatient in the Java 8 forum!

JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "JDBC - Date" Watch "JDBC - Date" New topic
Author

JDBC - Date

sudha swami
Ranch Hand

Joined: Apr 24, 2007
Posts: 179
Hi,
I want to retrieve the useraccounts data from last 8 days. how this can be done using JDBC?
regards
sudha
Jan Cumps
Bartender

Joined: Dec 20, 2006
Posts: 2531
    
  10

Sudha ,

please provide a little bit more info:
Tell us what you already tried to achieve this (your sql), some info on the table structure, and the type of database.

Regards, Jan


OCUP UML fundamental and ITIL foundation
youtube channel
sudha swami
Ranch Hand

Joined: Apr 24, 2007
Posts: 179
Hi,
I need to retrieve all the records from UserAccount table for last 2 days in Oracle Database.
eg:
UserAccount Table
------------------
UserID number
UserName Varchar2.
TimeStamp Date
Any help is appreciated.

regards
sudha
sudha swami
Ranch Hand

Joined: Apr 24, 2007
Posts: 179
Hi,
I have comeup with the following query.
select * from USERACCOUNT WHERE TIMESTAMP >= sysdate and TIMESTAMP <= (sysdate -3).
Yet to do the testing. If you have any other suggestions, please let me know.
sudha
Jan Cumps
Bartender

Joined: Dec 20, 2006
Posts: 2531
    
  10

If the last two days means yesterday and the day before:Regards, Jan
sudha swami
Ranch Hand

Joined: Apr 24, 2007
Posts: 179
Thanks Jan
sudha swami
Ranch Hand

Joined: Apr 24, 2007
Posts: 179
Jan,
Can you please let me know, the reason behind the trunc function in the sql sent by you
sudha
Jan Cumps
Bartender

Joined: Dec 20, 2006
Posts: 2531
    
  10

trunc() cuts the hours of a timestamp.

try running this (untested , I don't have an Oracle database at hand) example in sql*plus:Regards, Jan
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JDBC - Date