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

Date Diff

Status
Not open for further replies.

ryan1

Programmer
May 15, 2002
106
US
I have a many query that records dates. I'm trying to find the difference in days between a date to the next date which are in decending order(there are 20 or so dates). Any Suggestions?
 
You can try this. Change your Table name for Table1 and your date field for DateField. Table1_1 is the result of adding Table1 to the query twice so just change the Table1 part and leave the _1 when you change table names.

SELECT Table1.DateField, Max(Table1_1.DateField) AS MaxOfDateField, Table1DateField - MaxOfDateField As DifferenceInDays
FROM Table1, Table1 AS Table1_1
WHERE (((Table1.DateField)<Table1_1.DateField))
GROUP BY Table1.DateField
ORDER BY Table1.DateField DESC;

Try it and post back with problems. Because we don't have other fields to group on, I'm not sure how just date fields will preform in this situation.

Paul
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top