title: date to day function - MySQL - help needed
body: <p>I'm trying to create a MySQL function where I supply the date column and I get the day back in a new column using the below function. This is what I have. The select statement works fine outside the function - I tested it there. Can anyone help get this function going.
  Thanks</p>
  
  <pre><code>CREATE FUNCTION `GetWeekDayNameOfDate`(`Date1` date)
  RETURNS VARCHAR(50)
  LANGUAGE SQL
  DETERMINISTIC
  CONTAINS SQL
  SQL SECURITY DEFINER
  COMMENT ''
  BEGIN
  
  DECLARE DayName1 varchar(50)
  
  SELECT
  CASE DATE_FORMAT(Date1 , '%w' ) 
  WHEN 0 THEN 'Sunday'
  WHEN 1 THEN 'Monday'
  WHEN 2 THEN 'Tuesday'
  WHEN 3 THEN 'Wednesday'
  WHEN 4 THEN 'Thursday'
  WHEN 5 THEN 'Friday'
  WHEN 6 THEN 'Saturday' else null end;
  
  
  RETURN DayName1;
  
  END
  </code></pre>