MySQL Forums
Forum List  »  General

MICROSECOND being lost in stored function
Posted by: Larry D. Wilson
Date: October 15, 2010 03:58PM

I've been hammering on this all day, and I suspect either I'm doing something really dumb, or this is a bug - wanted to run it by all the gurus out there before I submit it.
When a timestamp or time value is passed to a stored function, it's not retaining the MICROSECOND value.
How to repeat - first create a test function:
DELIMITER $$
DROP FUNCTION IF EXISTS `f_test_time`
$$
CREATE FUNCTION `f_test_time`(
p_time TIME)
RETURNS INT
BEGIN
RETURN MICROSECOND(p_time);
END;
$$

And then run:
DELIMITER $$
SET @time = CAST('2010-10-14 14:21:27.019473' AS TIME);
$$
SELECT `f_test_time`(@time);
$$
SELECT MICROSECOND(@time);
$$

The first statement calling the function returns 0, yet the simple select statement returns the microseconds.
Anyone see anything weird?
And thanks for taking a look at this.

Options: ReplyQuote


Subject
Written By
Posted
MICROSECOND being lost in stored function
October 15, 2010 03:58PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.