Bug #54958 datediff does not work with variables in ``
Submitted: 2 Jul 2010 11:35 Modified: 2 Jul 2010 12:23
Reporter: Meik Suchlich Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Server Severity:S2 (Serious)
Version:5.1.47 OS:Linux
Assigned to: CPU Architecture:Any
Tags: DATEDIFF

[2 Jul 2010 11:35] Meik Suchlich
Description:
Hello,

we upgraded our database from 5.0.53 to 5.1.47 and now the function datediff does not work any more with variables in ``, if you have the max-function for the declared variable.

Thanks for help!

Meik

How to repeat:
Test:
Try any call with datediff(now(), `testdate`)

create table datum (
datefrom datetime
);
insert into datum
values (now());

select max(datefrom) as `testdate`
from datum
having
datediff(date(now()), `testdate`) < 7

You get an unknown column error in having clause. 
If you changet to

select datefrom as `testdate`
from datum
having
datediff(date(now()), testdate) < 7

it works

Suggested fix:
make datediff work with variable in `` as it worked before
[2 Jul 2010 12:23] Valeriy Kravchuk
This is a duplicate of bug #48150.