I am creating a Stored procedure in which ,
I am passing 2 IN parameters as ‘year’ & ‘month’ to a procedure,
then ” I need to store these both IN parameters in one variable in date_format like (‘YYYY-MM-DD’).”
And after that I want to use that variable with that Date_Format.
I will try to explain above things in stored procedures format
CREATE PROCEDURE build_table(IN years CHAR(5) ,IN months CHAR(4))
BEGIN
DECLARE format1 date ;
# Now i want to store both IN parameters in 'format1' variable and then format1 should be in format 'YYYY-MM-DD'
Can I do this in stored procedure?
If yes give me some guidance.
Tru to use this variant –
The STR_TO_DATE function will help you to make a date value. Change @year and @month variables with IN parameters.
Then you can use a DATE_FORMAT function to format datetime value, e.g.: