Insert php date("Y-m-d") directly into SQL query -
I am currently running a SQL query to count the results from tomorrow I am trying to shorten my code and I am thinking that if there is a method, then I can include the following command ...
Date ("YMD", strotome ('1 day')); directly into my query? Currently I am specifying this variable and then I am putting such variables ...
$ yesterday = date ("Y-M-D", strotome ('-1 day')); Select COUNT as my (*) and count my_table WHERE value from 'd01' and the date '% $'% '
You can use the mysql function to work as JOB
date = date (DATE_SUB (NOW), INTERVAL 1 day) More explanation here
mysql> Select DATE_SUB (NOW (), INTERVAL 1 day); + --------- ------------------------ + | DATE_SUB (NOW (), INTERVAL 1 day) | + ------------ --------------------- + 2014-04-20 07:27:01 | + --------------- ------------------ + 1 line set (0.03 seconds) mysql> Select DATE (DATE_SUB (NOW (), INTERVAL 1 day)); + --------------------------------------- + | DATE (DATE_SUB (NOW), INTERVAL 1 day)) | + --------------------------------------- + | 2014-04 -20 | + --------------------------------------- +
Comments
Post a Comment