Apr 12, 2007 #1 ianuk77 Programmer Joined Apr 7, 2007 Messages 7 Location 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 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
Apr 12, 2007 #2 feherke Programmer Joined Aug 5, 2002 Messages 9,541 Location RO 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. http://rootshell.be/~feherke/ Upvote 0 Downvote
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. http://rootshell.be/~feherke/
Apr 12, 2007 Thread starter #3 ianuk77 Programmer Joined Apr 7, 2007 Messages 7 Location GB Thanks for the quick reply Yes the data is in chronological order and the query worked perfect. Thankyou Ian Upvote 0 Downvote
Thanks for the quick reply Yes the data is in chronological order and the query worked perfect. Thankyou Ian