Procedure passed Datetime parameter problem
Hi,
I have a stored procedure in which I pass a datetime parameter. but for some reason it won't recognice it.
The parameter firstDate is passed, but when I try to set the new value for it I get either 'NULL' or '0000-00-00 00:00:00' as output for it. Why is that?
call sp_Month_Daily_Total_Count_Person(null);
I get: '0000-00-00 00:00:00', NULL as answer????
So how can I pass in a datetime value and change it like to the first of the month????
Here is my Code:
CREATE DEFINER=`root`@`%` PROCEDURE `sp_Month_Daily_Total_Count_Person`(IN firstDate DATETIME)
BEGIN
-- set date to first and last day of month
IF firstDate IS NULL THEN
SET firstDate := DATE_FORMAT(NOW(), '01-%m-%Y');
ELSE
SET firstDate := CONCAT(DATE_FORMAT(STR_TO_DATE(firstDate, '%d-%m-%Y'), '01-%m-%Y'));
END IF;
SET @last := CONCAT(DATE_FORMAT(LAST_DAY(STR_TO_DATE(firstDate, '%d-%m-%Y')), '%d-%m-%Y 23:59:59'));
SELECT firstDate AS First, @last as Last;
END
Thanks for any help.
Subject
Views
Written By
Posted
Procedure passed Datetime parameter problem
10807
October 06, 2016 07:58AM
1629
October 06, 2016 11:53AM
1436
October 12, 2016 03:05AM
1431
October 12, 2016 11:58AM
1176
October 17, 2016 04:10PM
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.