Help me revise mySQL query

I'm trying to check if the throttling date reminder is today and the throttling end date hasn't passed yet, but I don't want it to be displayed. The problem is that the query I made is not working in mysql. Can anyone help me revise my request?

Here is my request:

$query="select * from t_regulation where dt_reminder >= '$today' and dt_ended ='$today'"

      

0


a source to share


3 answers


It assumes your dt_reminder column type is DATETIME and not some timeline.



SELECT * FROM t_regulation WHERE DATE(dt_reminder) >= CURDATE() AND DATE(dt_ended) = CURDATE()

      

+2


a source


You can do a lot of funky things with date functions;



Mysql date / time functions

0


a source


Very often I run into the problem that my date variable is a string that hasn't been formatted correctly for the default date timestamp in Mysql.

Remember that this comparison must be "yyyy-mm-dd".

Also, since since the date has ended hasn't passed yet, there shouldn't be:

$ query = "select * from t_regulation, where dt_reminder> = '$ today' and (dt_ended> '$ today' or dt_ended is null)"

0


a source







All Articles