pj-away
09-18-2003, 06:02 AM
I have a problem with order by s_date
The code I have written is :-
<?
$today = date("Y-n-j");
$realtoday = date("j-n-Y");
$conn = db_connect();
mysql_select_db("somedatabase");
$query = "select DATE_FORMAT(s_date, '%Y %m %d')as s_date, DATE_FORMAT(s_date, '%d %m %Y')as n_date, DATE_FORMAT(f_date, '%d %m %Y')as f_date, e_number, s_location, notes, map_ref, info from sda_events where f_date > '".$today."' order by s_date" ;
$result = mysql_query($query);
The f_date > $today appears to work ok
But doing an order by s_date sorts in day order and does not appear to take into account of the month and year !
Can anyone help ?
thanks
Paul
NB I need to show dates in DDMMYYYY format
The code I have written is :-
<?
$today = date("Y-n-j");
$realtoday = date("j-n-Y");
$conn = db_connect();
mysql_select_db("somedatabase");
$query = "select DATE_FORMAT(s_date, '%Y %m %d')as s_date, DATE_FORMAT(s_date, '%d %m %Y')as n_date, DATE_FORMAT(f_date, '%d %m %Y')as f_date, e_number, s_location, notes, map_ref, info from sda_events where f_date > '".$today."' order by s_date" ;
$result = mysql_query($query);
The f_date > $today appears to work ok
But doing an order by s_date sorts in day order and does not appear to take into account of the month and year !
Can anyone help ?
thanks
Paul
NB I need to show dates in DDMMYYYY format