Date calculation in a procedure

Submitted by:Andery Smith

Date added:31 December, 2011

Category:SQL

How to create a procedure for date calculation

Tags: date calculation

Code Snippet:

CREATE PROCEDURE myProc()
BEGIN

DECLARE TwentyYearsAgoToday DATE;
DECLARE mystring VARCHAR(250);

SET TwentyYearsAgoToday=DATE_SUB(curdate(), interval 20 year);
SET mystring=CONCAT('It was ',TwentyYearsAgoToday,' ...');

SELECT mystring;

END
 
 

Comments