get records from mysql table where datatime is less than current datetime -


i have table named trackhistory tracks change in table user. trackhistory table has column changeddate of datatype datetime records when change made in table user. want rows table trackhistory changeddate columns contains date less current datetime

for eg

table trackhistory

row_no.         changeddate            userid       marks 1             2016-02-08 08:45:34     5             40 2             2016-02-08 08:45:34     6             30 3             2016-02-08 09:12:34     5             50 4             2016-02-08 09:40:30     5             70 5             2016-02-08 09:40:30     6             60 

suppose in system current time 2016-02-08 10:10:20

since 4th , 5th row last change made in trackhistory table. row 4th , 5th rows changeddate less current time.

so how can write mysql query select rows changeddate less current date. in word, how can last updated rows trackhistory table.

thanks in advance.

just depends mean "just less current datetime"; can define interval.

select * trackhistory changeddate < now() , changeddate > date_sub( now() , interval 10 seconds ); 

see mysql function , date_sub function


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -