Thursday, December 8, 2011

incompatibility between Google Cloud SQL and MySQL 5.5

I have the following function tested and working on a local MySQL 5.5
installation:

CREATE FUNCTION epoch_milliseconds (a DATETIME) RETURNS BIGINT
DETERMINISTIC
BEGIN
RETURN TIMESTAMPDIFF(MICROSECOND,'1970-01-01',a);
END

When I run:

SELECT epoch_microseconds('2011-12-08 21:46:15.214000');

I get:

1323380775214000

When I run the same function on Cloud SQL I get:

1323380775000000

Basically, it appears Cloud SQL has less precision than MySQL 5.5 for
the TIMESTAMPDIFF function.

Any ideas why Cloud SQL is returning a different value than MySQL 5.5?

No comments:

Post a Comment