Reputation: 33
I am trying to parse two date parameters from a SP to be used in the select statements where clause.
It seems that am getting an: ERROR 1292 (22007): Incorrect date value.
Code snippet below:
create procedure db_name.sp_name(in start_date date, in end_date date)
select * from db_name.db_table
where date_column >= start_date and date_column <= end_date;
Please advise. Thanks a bunch in advance.
Upvotes: 3
Views: 12418
Reputation: 133370
could be you need a proper date formatting supposing you pass start_date and end_date in '%Y-%m-d%' format
create procedure db_name.sp_name(in start_date date, in end_date date)
select * from db_name.db_table
where date_column >= str_to_date(start_date, '%Y-%m-%%')
and date_column <= str_to_date(end_date, '%Y-%m-d%');
Upvotes: 5