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

DateTime question

Status
Not open for further replies.

ianuk77

Programmer
Apr 7, 2007
7
GB
Hi all,

Is it possible to get the datetime value of the first and last records in a table then work out the difference between ?


Thanks,

Ian
 
Hi

If the data is in chronological order, so the first is the oldest and the last is the newest date, then is easy :
Code:
[b]select[/b]
min([green][i]thefield[/i][/green]),max([green][i]thefield[/i][/green]),datediff(max([green][i]thefield[/i][/green]),min([green][i]thefield[/i][/green]))
[b]from[/b] [green][i]thetable[/i][/green]

Feherke.
 
Thanks for the quick reply :)

Yes the data is in chronological order and the query worked perfect.

Thankyou
Ian
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top