Jump to content

Order by month query


monkeybidz

Recommended Posts

I am trying to order by a certain month only, say January for instance. The current script calls all months available in database. Below is a part of the code i need help with.
[code]
$query = "SELECT a.starts FROM NAMEOFMYDATABASE_problem a WHERE
            a.starts=starts ORDER BY a.starts ASC limit $offset, $limit";
            $result = mysql_query($query);
            $tmp_date = mysql_result($result,$i,"a.starts");
            $month = substr($tmp_date,4,2);
            $day = substr($tmp_date,6,2);
            $year = substr($tmp_date,0,4);
            $date = "$month/$day/$year";
[/code]

What can i do to order data for january only since it uses a substr temp date?

Thanks in advance.
Link to comment
Share on other sites

just change your query to grab the month you need.

ie. for January

SELECT a.starts FROM NAMEOFMYDATABASE_problem a WHERE
a.starts=starts AND MONTH(a.starts)='1' ORDER BY a.starts ASC limit $offset, $limit
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.