-1

I have set up cronjob wherein MySQL query there are used NOW SQL function at lots of time. I want to run cronjob for a past date so I need to change in code. But I think if I will change return static past date value in now function of SQL then I can do a thing without code change.

My current code in cronjob.

....
$query = "SELECT * from table_name where from_date <= DATE(NOW())";
....
Bhavin Thummar
  • 1,255
  • 1
  • 12
  • 29

2 Answers2

1

You can set the system variable timestamp to set a time that is returned by NOW()

danblack
  • 12,130
  • 2
  • 22
  • 41
0

Why you need to override, Its not feasible? You can use past date instead of now as you specified in question!!

$query = "SELECT * from table_name where from_date <= 'yyyy-mm-dd H:i:S'";
$query = "SELECT * from table_name where from_date <= '2018-05-05 05:05:05'";
Kiran
  • 1,176
  • 2
  • 14
  • 27