compare dates within the sql query

Asked

Viewed 27 times

2

I need to compare the date registered in the bank +10 days with the current date and display the student that the current date is greater than 10 days, but this within the sql query. Is there a function for that? I tried it, unsuccessfully.

$dataMais10 = date('Y-m-d', strtotime('-10 days'));
SELECT aluno,title,dt_banco FROM liberar WHERE dt_banco < {$dataMais10}

OBS. I cannot recover dt_banco before consultation.

1 answer

1


It’ll be something like this?

SELECT  aluno,title
    ,   dt_banco 
FROM    liberar 
WHERE   DATE_ADD(dt_banco, INTERVAL 10 DAY) < CURDATE()

Basically the query is getting all records from the table liberar where the value of the column dt_banco + 10 days is less than the current date.

  • our this solved, I only changed the < to > because I need to display the student in which the current date is greater than the 10 days, there functional.

Browser other questions tagged

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