Re: DateDiff
- From: "Michel Walsh" <vanderghast@VirusAreFunnierThanSpam>
- Date: Thu, 13 Jul 2006 18:06:56 -0400
Hi,
SELECT a.aircraft, a.eventDate, b.eventDate, a.eventDate-b.eventDate As diff
FROM ( myTable As a INNER JOIN myTable As b
ON a.aircraft = b.aircraft AND a.eventDate < b.eventDate)
INNER JOIN myTable As c
ON a.aircraft = c.aircraft AND a.eventDate < c.eventDate
GROUP BY a.aircraft, a.eventDate, b.eventDate
HAVING b.eventDate = MIN(c.eventDate)
You can then use a crosstab on the result of that query if you want an
horizontal display, with all possible diff (as columns), aircraft as group
(lines) and COUNT (as cell).
Hoping it may help,
Vanderghast, Access MVP
"MJE" <MJE@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:3D41DE7F-DA0A-4E23-96AE-9E258765083E@xxxxxxxxxxxxxxxx
I have a table that looks like this:
Aircraft Event Date
1 1/1/06
1 2/1/06
2 1/1/06
1 3/1/06
2 2/1/06
I need a query that provides the difference between each pair of dates
(there may be up to 20 pairs) similar to the following:
Aircraft Datedif1 Datedif2 .... Datedif(n)
I've tried using crosstab queries, but am having no luck. Any suggestions
would be appreciated!
.
- Prev by Date: Re: find unique rows
- Next by Date: Re: Help with WHERE part of SQL statement
- Previous by thread: Re: Creating Dates in a Query
- Next by thread: Re: Help with WHERE part of SQL statement
- Index(es):
Relevant Pages
|