• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 204
  • Last Modified:

adding value to IN variable

I need to assign 21600000 to fromDate IF the value originally sent in is zero

Code that I have now is

CREATE PROCEDURE reportFreeCooling(
  IN fromDate VARCHAR (50),
  IN toDate   VARCHAR (50),
  IN timeZone VARCHAR (50)
  DECLARE startDate VARCHAR (50);
  DECLARE endDate   VARCHAR (50);
  DECLARE startDateOriginal VARCHAR (50);
  DECLARE mylogID   INT;
  DECLARE myItemId varchar (50);
  DECLARE myItemId2 varchar (50);
  DECLARE xHours varchar (50);
  DECLARE endHoursNull varchar(50);
  DECLARE endHoursNotNull varchar (50);


Open in new window

and of course the rest of the stored procedure. The rest is correct I just need to know how to change the fromDate if zero is what is sent in.
1 Solution
portlightAuthor Commented:
I have tried this but it is also not working
basically this is what i need to code to do.....

 IF fromDate = 0 THEN 
  SET @fromDate = '21600000';
  IF fromDate > 0 THEN SET @romDate = fromDate;
  SET startDate = FROM_UNIXTIME(@fromDate/1000); 

Open in new window

This works for me:

CREATE DEFINER=`root`@`localhost` PROCEDURE `reportFreeCooling`(
  IN fromDate VARCHAR (50),
  IN toDate   VARCHAR (50),
  IN timeZone VARCHAR (50)
	IF fromDate = 0 THEN SET fromDate = '23423'; END IF;
	SELECT fromDate;

Open in new window

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now