I'm looking to setup a calendar date stored procedure in Mysql. The purpose is to be able to select the first day and last day of a given month by call the procedure. I know it is probably a very simple thing that I am missing. Below is what I have tried.
CREATE PROCEDURE CalendarDate
@startdate DATE,
@enddate DATE
AS
SELECT
(SELECT DATE_ADD(DATE_ADD(LAST_DAY(CURDATE()),interval 1 DAY),interval -1 MONTH)) AS startdate
, (SELECT LAST_DAY(CURDATE())) AS enddate
;
I would like to use the above to be able run a query by just saying:
SELECT *
FROM mytable
WHERE action_date BETWEEN @startdate AND @ endate