aspose file tools*
The moose likes JDBC and the fly likes JDBC - Date Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
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: 2477
    
    7

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: 2477
    
    7

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: 2477
    
    7

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
 
Similar Threads
Need help to write a bot to collect data from internet.
Loading file data into a DB2 table using java
java sql parser
WA #1.....word association
Need guidance for SCJD exam preparation