calculate date difference for grouped data

G

Guest

I have data in one of my tables in the following format.

Work_Order date
a1 d1
a1 d2
a1 d1
a2 d3
a2 d4
a3 d5
a3 d5
a3 d6

I need to display the Work_Order values wherein the Date Difference would be
less than 60 days. Example, for a1, if Diff(d1,d2) < 60 then I need to
display them otherwise I dont wanna display any data. Any ideas.

Thanks.
DD.
 
J

John Spencer

Do you want the difference between the oldest and newest date for a work
order?

SELECT Work_Order
FROM YourTable
GROUP BY Work_Order
HAVING DateDiff("d",Min([Date],Max([Date]) > 60

If this is not what you want, expand on your problem.
 
G

Guest

Thanks. Did some minor tweaking and it worked.

John Spencer said:
Do you want the difference between the oldest and newest date for a work
order?

SELECT Work_Order
FROM YourTable
GROUP BY Work_Order
HAVING DateDiff("d",Min([Date],Max([Date]) > 60

If this is not what you want, expand on your problem.

DD said:
I have data in one of my tables in the following format.

Work_Order date
a1 d1
a1 d2
a1 d1
a2 d3
a2 d4
a3 d5
a3 d5
a3 d6

I need to display the Work_Order values wherein the Date Difference would
be
less than 60 days. Example, for a1, if Diff(d1,d2) < 60 then I need to
display them otherwise I dont wanna display any data. Any ideas.

Thanks.
DD.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top