pandemic pandemic - 3 months ago 9
MySQL Question

Before and After in mySql

Is it possible in MySql to do before and after in the same statement, my data is getting too large and i want to show only the data that has a date of 3 months before and 3 months after "FollowUp". It is date-time col. This is my statement..

select * from valuations
where Consultant = '$user'
and FollowedUp = 0 Order by FollowUp desc";

Answer

Use this code

select * from valuations 
        where Consultant = '$user'
        AND FollowUp  >= NOW() - INTERVAL 3 MONTH
        AND FollowUp  <= NOW() + INTERVAL 3 MONTH
        and FollowedUp = 0 Order by FollowUp desc";