March 9, 2005 at 6:33 am
Hey,
I have a datetime stamp that returns values in this format: 2005-03-08 13:15:44.880
What I want to do is do a range filter on this column where it is within 1 minute of the value in that field currently.
For example, for this value, I want to do a range from 2005-03-08 13:14:44.880 to 2005-03-08 13:16:44.880
Any ideas?
Thanks,
Michael
March 9, 2005 at 6:44 am
Here's a straight forward way that probably won't use available indexes...
SELECT yada-yada
FROM yourtable
WHERE datediff(mi,0,datecolumn)= datediff(mi,0,datetimelookingfor)
Here's a less straight forward way that will use available indexes...
SELECT yada-yada
FROM yourtable
WHERE datecolunmn >= dateadd(mi,datediff(mi,0,datetimelookingfor),0)
AND datecolunmn < dateadd(mi,datediff(mi,0,datetimelookingfor)+1,0)
Sorry, forgot to add the "dateadd". Had to update this post.
--Jeff Moden
Change is inevitable... Change for the better is not.
March 9, 2005 at 6:47 am
Would this help?
select *
from myTable
where dateColumn >= dateadd(mi, -1, '2005-03-08 13:15:44.880')
and dateColumn <= dateadd(mi, 1, '2005-03-08 13:15:44.880')
/Kenneth
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply