How not to display past date records

Asked

Viewed 125 times

5

I made a schedule and I need events that have already passed not appear anymore, dates are with 3 fields DAY/MONTH/YEAR, I am using the Concat and date to join and format the dates, so this is the current query:

$query = mysql_query("SELECT * FROM `tabela1` WHERE `evento` LIKE '%$busca%' ORDER BY date(concat(ano,'-', mes,'-',dia)) ASC") or die(mysql_error());

1 answer

3


SELECT *
FROM `tabela1`
WHERE `evento` LIKE '%$busca%'
AND `nomeDoCampoData` > '2014-04-10'
ORDER BY date(concat(ano,'-', mes,'-',dia)) ASC

If you want to take between a period use the between

SELECT *
FROM `tabela1` 
WHERE `evento` LIKE '%$busca%'
AND `nomeDoCampoData` BETWEEN '2014-04-10' AND '2014-04-13'
ORDER BY `nomeDoCampoData`

Tip do not use a field for each one: date, month, year... Use only one field of type DATE

  • Valew, I got the code q vc just posted and made some modifications!!! is in the edited topic...

Browser other questions tagged

You are not signed in. Login or sign up in order to post.