Search code examples
phpmysqldatefuturetask

selection of future date records from mysql database table


enter image description here

Architecture of my table is as following:

enter image description here

I have the above table, wherein date datatype filed "l_from", i want to select all those records which having today date or all the future date from now.

For this i have used the following queries:

SELECT emp_sno,emp_type,l_from,l_to,l_nature 
FROM leaves_history 
WHERE l_from < CURDATE() AND emp_type = 1

But the above query does not help.
I have changed the

where l_from >= curdate()

where l_from <= curdate() 

but in no clause return the highlighted row.

What should i have to change in?

thanks in advance


Solution

  • Give this a go?

    SELECT emp_sno,emp_type, l_from, l_to, l_nature 
    FROM leaves_history 
    WHERE l_from <= NOW() AND emp_type = 1
    

    EDIT Changed <= to >=

    SELECT emp_sno,emp_type, l_from, l_to, l_nature 
    FROM leaves_history 
    WHERE l_from >= DATE(NOW()) AND emp_type = 1