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!

Get Earliest date and Last date then subtract 1

Status
Not open for further replies.

din2005

Programmer
Mar 22, 2005
162
GB
Hi all,

What i would like to do in query is to get the earliest date for patient treatment (patient may have 1 to 5 or greater treatments) and the final date of the patient treatment then subtract them (using datediff which i can do).

I have over 5000 records is it possible to display all the dates in one table. i.e create an extra field or something. could someone give me an example or some criteria.

Many thanks
 
Something like this ?
SELECT [patient treatment], Min([date field]) AS EarliestDate, Max([date field]) AS FinalDate, Int(Max([date field])-Min([date field])) AS CountOfDays
FROM yourTable
GROUP BY [patient treatment];

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top