E
E
eldar_web2015-08-09 09:55:33
MySQL
eldar_web, 2015-08-09 09:55:33

How to select a record (outdated) in SQL where today's date is higher than the creation date?

There is, for example, the date of creation of the entry, in the variable $data='09/05/2015'.
And there is today's date: 08/09/2015
How to select a record from the database where the record creation date is older than today's date (or vice versa)?
I tried this, it doesn’t work (I know that I need to convert the date and process it, but I don’t know):

SELECT * FROM table WHERE table.date > '09.08.2015';

Answer the question

In order to leave comments, you need to log in

3 answer(s)
P
pesenka1, 2015-08-09
@pesenka1

www.techonthenet.com/mysql/functions/str_to_date.php
www.w3schools.com/sql/func_curdate.asp

A
AlikDex, 2015-08-09
@AlikDex

This query will use indexes. Time to store in timestamp.

SELECT * FROM table WHERE DATE(table.date) > STR_TO_DATE('2015-08-09', '%Y-%m-%d');

A
Alexey Lebedev, 2015-08-09
@swanrnd

Make a date in UnixTime, or make your own reporting system, let's say the number of days after 01/01/2015.
Maybe fit in 2 bytes)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question