Jump to content

Order by date


web_master

Recommended Posts

Hi,

 

<?php 
$QueryReturn = mysql_query('SELECT
	`ra_progbyday_year`,
	`ra_progbyday_month`,
	`ra_progbyday_day`
FROM
	`ra_progbyday`
ORDER BY
	??? ASC
');

?>

 

I got this query. `ra_progbyday_year`, `ra_progbyday_month` and `ra_progbyday_day` is an INT which is after reload for example: `ra_progbyday_year` = 2009, `ra_progbyday_month` = 04 and `ra_progbyday_day` = 04.

 

I got problem after ORDER BY, because I want to "ORDER" by date after reload. How can I list this 3 params like "date"?

 

- Or its enough to create column: `ra_progbyday_date` looks like: 20090404

 

Always will have a earlier date smaller nr that later date?

 

thnanx

T

 

 

Link to comment
https://forums.phpfreaks.com/topic/152560-order-by-date/
Share on other sites

You can use a timestamp column to order things by their date. You can also order them using their month and year columns...

 

ORDER BY year DESC, month DESC

 

Haven't ever done it, but I'd imagine you can use any number of columns to order the data with... So try ORDER BY year DESC, month DESC, day DESC too if you want.

Link to comment
https://forums.phpfreaks.com/topic/152560-order-by-date/#findComment-801272
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.