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

Finding DateDiff between Min(Date) & Max(Date)

Status
Not open for further replies.

londonkiwi

Programmer
Joined
Sep 25, 2000
Messages
83
Location
NZ
Firstly, I have checked through the Tek-Tips dbase to see if any answers have been provided previously - none?

I have a "Date" Field in a Table. In a query, I have found the min(DATE) and max(Date) dates eg 18/09/2001 and 27/09/2001. How do you then find the number of days between min(DATE) and max(DATE)

SQL as below

SELECT Min(IT.DATE) AS DATE_MIN, Max(IT.DATE) AS DATE_MAX, DateDiff("y",[min(Date)],[max(Date)]) AS DaysElapsed
FROM IT;

cheers
thanks in advance
The "DaysElapsed" fails.
 
Try this...

SELECT Min(IT.DATE) AS DATE_MIN, Max(IT.DATE) AS DATE_MAX, DateDiff("d",Min([Date]),Max([Date])) AS DaysElapsed
FROM IT;
 


Hi

Are you sure you want to do this through SQL?

If this is just something to be displayed on a form - then use Dmax/Dmin to pull out the values and then datediff to find the difference.

If you like formulas then use:

=DateDiff("d",DMin("[FieldName]","[TableName]"),DMax("[FieldName]","[TableName]"))

Is this what you want?


Stew "Even a stopped clock tells the right time twice a day."
 
Great guys - thnaks for both the replies. Worked a treat
 
Thanks everyone - works well.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top