DateDiff in query (1 Viewer)

papadega3000

Registered User.
Local time
Today, 00:18
Joined
Jun 21, 2007
Messages
80
Hello,

I have a table in a form to track changes to items in source table. Items are copied in by selecting the items in drop downs and after a button click the item needing editing is copied into this tracking table. Now what I want to accomplish is too build a query (ultimately to drive a report) to show the latest changes to the current day. Since I may or may not be making more than one edit to each item.
Essentially if I have a duplicate item in the list I want to determine which item came first. How is this accomplished?

My first idea was to DateDiff to quantify the difference between the current day and the timestamp(from the table) But I can't seem to find a way to be able to check duplicates entries.

Any ideas would be helpful.
 

Alc

Registered User.
Local time
Today, 00:18
Joined
Mar 23, 2007
Messages
2,407
Would it be possible to add a field to this tracking table to store the date the record is inserted? If so, you could sort by the column, in descending order, and that would give you the most recent.
 

papadega3000

Registered User.
Local time
Today, 00:18
Joined
Jun 21, 2007
Messages
80
Hello,

Thanks for the idea. That is not a bad idea, but only one catch is I want to filter the table in such a way that I can show every entry that has the same task ( a field in that table) Now this table will possible mutiple entries for the same task so I would want to grab all of them and if there is more than one whichever one is the latest one.

I might end up writing a sort of function to dinstiguish between to task which one is later and either removing the old one from the table or something like that. The only thing I am not sure of is how to actually write that function or criteria?

Any other idea's?
 

Alc

Registered User.
Local time
Today, 00:18
Joined
Mar 23, 2007
Messages
2,407
What's the table structure?

If it's how I'm picturing it, you could filter with a query along the lines of
SELECT *
FROM tablename
WHERE Activity = YourActivity
ORDER By DateField DESC;

That would give all activities of the one type, sorted by entry date, most recent at the top.
 

papadega3000

Registered User.
Local time
Today, 00:18
Joined
Jun 21, 2007
Messages
80
Thanks for the replies.

Alc and Brian your suggestions seems like it may work to what I am looking for. A mix of the two may work nicely.

FYI. The table has about 8 fields containing data about Tasks where the Task is the Primary Key in which I allow duplicates. So far keeping it as the primary key has made it easier writing queries since I have another similar table for a different purpose.

Anyways I will try it out and see what comes out.

Thanks again.
 

papadega3000

Registered User.
Local time
Today, 00:18
Joined
Jun 21, 2007
Messages
80
Hello,

Thanks for the suggestion on the query it worked using that method.
 

Users who are viewing this thread

Top Bottom