• Notice regarding image hosts and attachments. See here.

Php / MySQL date sort function

Associate
Joined
25 Aug 2004
Posts
163
Location
Reading
I have a php date variable (either as it is or as a timestamp) and I want to get the closest matching value to that date from the MySQL database, which there may be more than one of. Is there anyway of doing that in a query or do I have to pull everything in a 'select *' query and sort through the array and use my value as a pointer and select the above or below value? And I need to just select one date (or the set at that date rather) if there is the same distance between the date below and above the current date. It's bugging me now!

Cheers,

Gareth
 
That's true. I'm going for the query option for sure. I know there's not going to be more than a few thousand entries, still always nicer to have the results you want returned for php to handle as opposed to the whole table!
 
Back
Top Bottom