Using FLOOR() in WHERE clause in MySQL

446 views Asked by At

Is it possible to use FLOOR() in a WHERE clause, and if so, could someone tell me why the below code is wrong?

I have understood a lot from research on what it is and how to use it, but I cannot find anything which could fix this error.

select * from medications 
where floor(datediff('d', date(update_time) – date(insert_time))) <=1

My intention is to pull all records which have been amended in the last X number of days, where X <= 1 in this case.

Having readdressed it and considered people's comments below, I have decided to just use the code below. I hadn't really understood FLOOR() well enough to use it. The one below works for me.

m.updt_time >= (DATE_SUB(CURDATE(), INTERVAL 10 day))

It substitutes the number of days for a Crystal Reports parameter.

1

There are 1 answers

0
MrrMan On BEST ANSWER

Having readdressed it and considered people's comments below, I have decided to just use the code below. I hadn't really understood FLOOR() well enough to use it. The one below works for me.

m.updt_time >= (DATE_SUB(CURDATE(), INTERVAL 10 day))

I substitute the number of days for a Crystal Reports parameter.