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

last date

Status
Not open for further replies.

notstock78

Technical User
Jul 13, 2005
9
US
In my database I have a new entry entered automatically every so often. The entry does not have a specific time that it enters but the time it is entered is kept track of. I am trying to pull the most recent entry to the database using MSSQL but I cannot get it correct. I have pulled all the entries for the last hour and even down to the last 1/2 hour but this will still not pull all the records that I am looking for because some times it takes 3 hours to get one entry and sometimes I will get 6 in 1 hour.
 
First, this is probably not the best forum in which to pose your question. You would do better in the SQL Server Forum
forum183
Second, we need to understand your table structure to further assist with the question. What columns do you have which can identify the most recent record? Do you have an incrementing identity column? A date-inserted column?


-------------------------
The trouble with doing something right the first time is that nobody appreciates how difficult it was - Steven Wright
 
OK, this table keeps track of different positions of our vehicles with satalite positioning. We have many different vehicles with each there own ID. There is another column with the date and time when the truck was pinged. This is what I have so far.

select POSHIST.processed, POSHIST.tmwin_loc, MOBILE_DEVICE.ASSIGNED_TO
from POSHIST, MOBILE_DEVICE
where POSHIST.DEVICE=MOBILE_DEVICE.DEVICE_ID
AND PROCESSED BETWEEN CURRENT TIMESTAMP - 1 hours AND
CURRENT TIMESTAMP + .25 hours
ORDER BY ASSIGNED_TO


I am sure you already know that the PROCESSED is the date and time stamp that the truck is pinged and the MOBILE_DEVICE.ASSIGNED_TO is the truck ID.

I hope this is what you where asking. As you can tell, I am just learing how to use SQL.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top