List:General Discussion« Previous MessageNext Message »
From:Kent Roberts Date:August 9 2005 2:42pm
Subject:Stored Procedure, Dates, and Between
View as plain text  
I have a simple SP that is selecting rows based on a date range using parameters. I've
tried several permutations that all return 0 rows.

The select statement looks like this:

select * from 'mit_log'.'mitlog' where StartDateTime between '2005-04-01' and '2005-04-07'

and returns over 300,000 rows. The SP looks like this:

-----------------------------------------------------------------------------------------------------------------
DELIMITER $$

DROP PROCEDURE IF EXISTS `mit_logs`.`spPatientsLikeUsersByDate`$$

Create procedure `mit_logs`.`spUsingDateRange`(begDate datetime, endDate datetime)
BEGIN
SELECT *
FROM mitlog
WHERE (mitlog.StartDateTime between @begDate And  @endDate);
END$$
-----------------------------------------------------------------------------------------------------------------

and compiles ok. The calling statement looks like this:

call spPatientsLikeUsersByDate ('2005-04-01','2005-04-07')

Like I said, I've tried several guesses at syntax with no luck. When I take out the
parameters and hard code the dates, it works.

Any ideas?

Thanks in advance,
Kent in Montana





Thread
Stored Procedure, Dates, and BetweenKent Roberts9 Aug
  • Re: Stored Procedure, Dates, and BetweenMark Matthews9 Aug
  • Re: Stored Procedure, Dates, and BetweenSGreen9 Aug
Re: Stored Procedure, Dates, and BetweenKent Roberts9 Aug
Re: Stored Procedure, Dates, and BetweenKent Roberts9 Aug
Re: Stored Procedure, Dates, and BetweenKent Roberts9 Aug