Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8328433
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T01:26:34+00:00 2026-06-09T01:26:34+00:00

Using a MySQL SELECT query via PHP, I would like to order my entries

  • 0

Using a MySQL SELECT query via PHP, I would like to order my entries by date. The query I’m using is:

$query = "SELECT title, file, oblong_pic, square_pic,
DATE_FORMAT(date, '%W %d %M %Y') AS date
FROM dyhamb ORDER BY date DESC";

I have four entries dated: 24/7/2012, 1/7/2012, 5/6/2012 and 10/4/2012 and would like them to be displayed in that order however they are being displayed as: 24/7/2012, 10/4/2010, 5/6/2012 and 1/7/2012.

I can only think that I’ve set my query up incorrectly somehow but I don’t see where I’ve gone wrong.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T01:26:35+00:00Added an answer on June 9, 2026 at 1:26 am

    %W in DATE_FORMAT is weekday name, so sort starts with that

    If you want to use date alias you should rewrite your sql query to:

    $query = "SELECT title, file, oblong_pic, square_pic, date AS sort_date,
    DATE_FORMAT(date, '%W %d %M %Y') AS date
    FROM dyhamb ORDER BY sort_date DESC";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using a PHP mySQL query. Struggling with a Joins. mysql_query(SELECT * FROM
I am using MySQL. I have several lookups like this: SELECT * from users
Using PHP and MySQL, I want to select only 6 rows from table which
I am using PHP 5 to create a query page for a MySQL database
I'm using a script to update my record via php in mySQL. All of
I am using mysql_query(INSERT INTO imaegs_backup SELECT * FROM images); in order to copy
I'm looking for help using sum() in my SQL query: SELECT links.id, count(DISTINCT stats.id)
How to set default VALUE in SubQuery result using mysql SELECT p.`id`, p.`name`, p.`class_name`,
I am using an IF statement in my mySQL SELECT statement and depending on
I am trying to select the last record from a table in MySQL using

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.