Subject: selecting data in datetime intervals
Posted By: Phathu Post Date: 8/29/2006 6:51:36 AM
Hi guys

I have a table with some data
eg

       dtime            | dat1 | dat2 | dat3
2000-12-12 12:23:45.777 | 0.66 | 0.544| 7
2000-12-12 12:23:47.777 | 54   | 56   | 0.99
2000-12-12 12:23:50.777 | 210  | 44   | 212
2000-12-12 12:23:52.777 | 0.21 | 45   | 0.11
2000-12-12 12:23:58.777 | 12   | 0.24 | 75
2000-12-12 12:24:01.777 | 34   | 4    | 0.22
2000-12-12 12:24:05.777 | 54   | 785  | 45
2000-12-12 12:24:08.777 | 2    | 20   | 21
...


lets say i want to SELECT all the data in an interval of
5sec. not evrything in between but every 5seconds
can anyone help me

Reply By: SQLScott Reply Date: 8/29/2006 3:53:25 PM
Look at the DATEPART function.  It will take a little work but it is doable.  For example, grab the first value, then use the DATEPART function to add 5 minutes to that value.  Then loop through the results looking for that value.  When found, use the DATEPART function again to add 5 minutes and loop again, repeating the process.  There is probably a way to do this without looping, but this is just the first thing that came to mind.


Go to topic 48754

Return to index page 190
Return to index page 189
Return to index page 188
Return to index page 187
Return to index page 186
Return to index page 185
Return to index page 184
Return to index page 183
Return to index page 182
Return to index page 181