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

  • Home
  • SEARCH
  • 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 8425913
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T04:24:20+00:00 2026-06-10T04:24:20+00:00

In my sql query I output dates in chronological order. The dates in my

  • 0

In my sql query I output dates in chronological order.

The dates in my database are stored in d-M-Y format.

What I want to do is sort the results by dates equal to or greater than today to be output first.

In my query I have this sort in my query

...From $db ORDER BY STR_TO_DATE(sortdate, '%d-%M-%Y') ASC

Can anyone tell me if I can do a comparison on todays date as each record is output from the db?

This will give me todays date

$todaysdate = date("d-M-Y", time());

but can anyone tell me if I can build that into my query?

Thanks in advance.

  • 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-10T04:24:22+00:00Added an answer on June 10, 2026 at 4:24 am

    My guess is that you saved the date in a VARCHAR column. Please don’t do that, you make it very complicated for yourself when you want to do stuff (like this) with the date. I’d suggest that you convert the column to a DATE field and then just use:

    SELECT * FROM my_table WHERE my_date_field >= CURDATE()
    

    And if you want to output the date in the d-m-Y format, you can use DATE_FORMAT()

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Describe the output of the following SQL query: select custId, name from customer where
The SQL query without where statement runs great and outputs good results, but when
By default if you compare two dates in a LINQ2SQL query, the resulting SQL
I have a problem displaying the results of an sql query into a ListView
Using C#.Net and MYSQL I want to use a CASE Statement like SQL Query
I have a sql-query where I ask for some dates. "SELECT DISTINCT date FROM
I'm coding a SQL query to look for events in a database. I use
I'm trying to output the result of my SQL query to a div using
I want to create an SQL Query for a SQLite3 DB. In my table
Using SQL Server 2000 How to avoid the duplicate values? Query SELECT DISTINCT Modification.dbo.Reference.Dates

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.