Hi All,
Please suggest on How to find record created in Last quarter using custom query?
Thanks,
Shreya
Hi All,
Please suggest on How to find record created in Last quarter using custom query?
Thanks,
Shreya
If you are looking for a query, mysql has formulas to get the first and last day of the quarter
SELECT MAKEDATE(YEAR(CURDATE()), 1) + INTERVAL QUARTER(CURDATE())-2 QUARTER as first_day_of_quarter, MAKEDATE(YEAR(CURDATE()), 1) + INTERVAL QUARTER(CURDATE())-1 QUARTER - INTERVAL 1 DAY as last_day_of_quarter
So, for example, to get all the opportunities from last quarter you can use:
select * from opportunities WHERE date(date_entered) <= MAKEDATE(YEAR(CURDATE()), 1) + INTERVAL QUARTER(CURDATE())-1 QUARTER - INTERVAL 1 DAY and date(date_entered) >= MAKEDATE(YEAR(CURDATE()), 1) + INTERVAL QUARTER(CURDATE())-2 QUARTER
FrancescaS
If you are looking for a query, mysql has formulas to get the first and last day of the quarter
SELECT MAKEDATE(YEAR(CURDATE()), 1) + INTERVAL QUARTER(CURDATE())-2 QUARTER as first_day_of_quarter, MAKEDATE(YEAR(CURDATE()), 1) + INTERVAL QUARTER(CURDATE())-1 QUARTER - INTERVAL 1 DAY as last_day_of_quarter
So, for example, to get all the opportunities from last quarter you can use:
select * from opportunities WHERE date(date_entered) <= MAKEDATE(YEAR(CURDATE()), 1) + INTERVAL QUARTER(CURDATE())-1 QUARTER - INTERVAL 1 DAY and date(date_entered) >= MAKEDATE(YEAR(CURDATE()), 1) + INTERVAL QUARTER(CURDATE())-2 QUARTER
FrancescaS