• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 202
  • 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)
)
BEGIN
  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.
0
portlight
Asked:
portlight
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

0
 
mankowitzCommented:
This works for me:

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

Open in new window

0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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