Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Query question: retrieving data with timestamp range

Status
Not open for further replies.

PFunkster

Technical User
Jul 24, 2001
4
US
i have the following sql for Oracle which i want to convert to use with DB2:

/**
* Oracle SQL that returns session IDENTIFIER value by USERID and between SYSDATE and SYSDATE - 5 minutes
*/
private static final String lastsessn_sql1 = "select IDENTIFIER from BCHISTSESSN " +
"where USERID = ? " +
"and STARTDT between (SYSDATE - 5/1440) " +
"and SYSDATE " +
"order by STARTDT DESC";

i've played around with the db2 syntax with no luck so far. i know that i can get the db2 instance's system time as such:

select distinct(CURRENT TIMESTAMP) from SYSIBM.SYSTABLES
which returns: Nov 19. 2004 11:29:30 AM 771001

if i use the following, nothing is returned, although i know there is valid activity within the 5 minute time period for this user:
select IDENTIFIER from bcHistSessn
where USERID = 694005277882043342185161000000
and (char(STARTDT) = (CURRENT TIMESTAMP - 5 MINUTES))

as of know, i've run out of ideas so any help would be appreciated.

thanks in advance!
 
i found the solution:
select IDENTIFIER from BCHISTSESSN
where USERID = ?
and STARTDT >= CURRENT TIMESTAMP - 5 MINUTES
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top