Click here to Skip to main content
15,881,641 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
select top 2000 Time_Stamp,LATITUDE,LONGITUDE,LOCATION from tablename where TIME_STAMP between '07/14/2012' and '07/22/2012' group by Time_Stamp,LATITUDE,LONGITUDE,LOCATION order by Time_Stamp desc

in the above query i mention dates between 07/14/2012 and 07/22/2012...but i am getting record from 07/14/2012 to 07/21/2012. so one day is missing if i am using the above query. so can any one assist me regarding this issue so that i can fetch the data exactly i.e without missing a day........
Posted

Then try something like this
SQL
select top 2000 Time_Stamp,LATITUDE,LONGITUDE,LOCATION from tablename where TIME_STAMP between '07/14/2012' and dateadd(D,1,'7/22/2012') group by Time_Stamp,LATITUDE,LONGITUDE,LOCATION order by Time_Stamp desc
 
Share this answer
 
When you say 7/22/2012 it will take records before 7/22/2012 00:00:000

So you have to say either '7/23/2012' or '7/22/2012 23:59:59'
SQL
select top 2000 Time_Stamp,LATITUDE,LONGITUDE,LOCATION from tablename where TIME_STAMP between '07/14/2012' and '07/23/2012' group by Time_Stamp,LATITUDE,LONGITUDE,LOCATION order by Time_Stamp desc


or
SQL
select top 2000 Time_Stamp,LATITUDE,LONGITUDE,LOCATION from tablename where TIME_STAMP between '07/14/2012' and '7/22/2012 23:59:59' group by Time_Stamp,LATITUDE,LONGITUDE,LOCATION order by Time_Stamp desc
 
Share this answer
 
TIMESTAMP will catch everything starting at midnight on the first day, and ending at 23:59:59 on the last day.So just increase logically one day with your last limit 07/22/2012 of BETWEEN days.
 
Share this answer
 
dude ur awesome....thanqqqqqq.......
 
Share this answer
 
Comments
Santhosh Kumar Jayaraman 17-Aug-12 2:45am    
Please mark the correct answer as accepted answer and please isntead of adding new solution,add comment.
kalyan10qwerty 17-Aug-12 2:46am    
ok ok....
Santhosh Kumar Jayaraman 17-Aug-12 2:53am    
only if you mark it as solved, other ppl will come to know the solution
kalyan10qwerty 17-Aug-12 3:00am    
i think u deleted ur query
Santhosh Kumar Jayaraman 17-Aug-12 3:02am    
its solution 3

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