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

Order Dates by Nearest to Today (not just asc and desc)

Status
Not open for further replies.

timtom

Programmer
Jul 12, 2001
78
GB
Hi,
I wonder if there's a way to order a group of dates (not including year) by 'nearness' to today's date? (With events just gone at the end of the list)
So I could create a page displaying information like this...

thing - 9th July
thing - 20th August
thing - 25th August
thing - 15th December
thing - 23rd December
thing - 3rd January
thing - 15th February
thing - 20th May
thing - 3rd July

All my information is in an SQL database. Thanks if anyone knows a way of doing this.
Thanks
Sarah :)
User_timtom.jpg
[sub]WASN'T FIT ENOUGH FOR THE POLICE FORCE[/sub]​
 
Really not sure what you're after here, but if it's what i'm thinking, how about something like:
Access:
select *
from table1
order by abs(datetimefield-now)
SQL Server:
select *
from table1
order by abs(datetimefield-current_timestamp) codestorm
Fire bad. Tree pretty. - Buffy
select * from population where talent > 'average'
<insert witticism here>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top