Jump to content

Help with statement to select row where dates previous to today.


Robbiez

Recommended Posts

HI

Can anyone help with a statement to select all rows from a table where the value of a column is earlier than today's date.
The date is stored as(for example) Monday 1 March %W %e %M

I was hoping something like this would work:

SELECT * FROM `table` WHERE DATE_FORMAT(dispatchdate, '%W %e %M') < NOW()-INTERVAL 1 DAY

Thanks

Link to comment
Share on other sites

16 minutes ago, Robbiez said:

The date is stored as(for example) Monday 1 March

Well there's your first problem. Store it as an actual DATE and format it when you display the value to the user, then working with it in your SQL will be much easier - and faster, more efficient, using fewer system resources, etc.

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.