Forums

select date related records

NickOg 01 Apr, 2019
I am trying to extract records older than 2 years.
I have this in my read data control
id/IN:{var:read_data43}
YEAR ( lastvisitDate )/>=:(YEAR( CURDATE() )-1)
but that forces this SQL

SELECT `mdlSelectReceiversOnReceipt`.`id` AS `mdlSelectReceiversOnReceipt.id`, `mdlSelectReceiversOnReceipt`.`username` AS `mdlSelectReceiversOnReceipt.username`
FROM `u3a_users` AS `mdlSelectReceiversOnReceipt`
WHERE `mdlSelectReceiversOnReceipt`.`id` IN ('1113', '591', '3362', '1876', '595', '2013', '3355', '1115', '3363', '592', '3356', '3360', '2869', '2120', '2149', '2148', '3364', '590', '2440', '', '582', '2607', '2654', '2648', '2826', '2868', '2875', '2872', '3091') AND
YEAR ( lastvisitDate ) >= '(YEAR( CURDATE() )-1)' ORDER BY `mdlSelectReceiversOnReceipt.username` ASC LIMIT 100000;

Note that '' around
'(YEAR( CURDATE() )-1)'

Tried all I can think of but NBG.

It works OK if I 'hard code' a value. For example
YEAR ( lastvisitDate )/>=:2018

I must be missing something again.

😡

Nick
healyhatman 01 Apr, 2019
Answer
If you really just want 2 calendar years
{date:Y$-2 years}
NickOg 01 Apr, 2019
That easy! Many thanls Work3ed a treat.

Nick
This topic is locked and no more replies can be posted.

VPS & Email Hosting 20% discount

{item:title} {images:#}