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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

TimeStamp issue in SQL

Status
Not open for further replies.

logic4fun

Programmer
Apr 24, 2003
85
0
0
US
Hi all,
I have a DB2 timestamp YYYY-MM-DD-HH.MM.SS and i need to pull data by Half Hour Intervals. i know commands Hour(timeStamp) or minute(timeStamp) can give me the data for Hour or Minute . ANY LOGIC for pulling out in HALF HOUR intervals.

thanks in Advance
logic4fun
 
Try simply dividing mins/30

For mins less than 30, you get a a fraction less than 1. For mins equal 30, you get 1. For mins greater than 30, you get a fraction greater than 1.

So, build your logic with:

if(mins/30 <= 1)
// first half of hour
else if(mins/30 > 1)
// second half of hour

Tim

Skypanther Studios
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top