Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JDBC - Date

 
sudha swami
Ranch Hand
Posts: 186
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I want to retrieve the useraccounts data from last 8 days. how this can be done using JDBC?
regards
sudha
 
Jan Cumps
Bartender
Posts: 2588
11
C++ Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
sudha swami
Ranch Hand
Posts: 186
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 186
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2588
11
C++ Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If the last two days means yesterday and the day before:Regards, Jan
 
sudha swami
Ranch Hand
Posts: 186
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Jan
 
sudha swami
Ranch Hand
Posts: 186
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jan,
Can you please let me know, the reason behind the trunc function in the sql sent by you
sudha
 
Jan Cumps
Bartender
Posts: 2588
11
C++ Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic