Click here to Skip to main content
15,123,118 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi all,
I got a data table with a field of type date time and i got data like 3-5 entries for every minute ie(23/08/2012 18:05:01,23/08/2012 18:05:15,23/08/2012 18:05:26,23/08/2012 18:05:44,23/08/2012 18:05:59), now i need to get data one record for every 5th minute
can any one please help me how can i do this one
Thanks
Posted
Comments
Sergey Alexandrovich Kryukov 23-Aug-12 13:14pm
   
This is not really a question. If you need to do it, you got my permission; please go ahead. :-)
--SA
SREEKAN2 23-Aug-12 13:22pm
   
can you please tell me how can i do this because i am struck here, i need to fetch records based the date time filed and one record for every 5 minutes
Sandeep Mewara 23-Aug-12 13:31pm
   
need to get data one record for every 5th minute
Write a query?
ridoy 23-Aug-12 13:49pm
   
what have you tried?

1 solution

SQL
select *
from
(
    select *,
       datepart(minute, yourDate) mn,
       row_number() over(partition by datepart(minute, yourDate) order by yourDate) rn
    from yourTable
) x
where (mn % 5) = 0
    and rn = 1
   
Comments
ridoy 23-Aug-12 14:37pm
   
good one..+5

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900