This is a discussion on time_zone and ERROR 1146 Table '.' doesn't exist within the MySQL Database forums, part of the Database Forums category; Hi, I need the unix_timestamp of the Nth day of the year, at 00:00:00. I have tried this ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Hi,
I need the unix_timestamp of the Nth day of the year, at 00:00:00. I have tried this function : CREATE FUNCTION jour (j integer ) RETURNS int(11) -> DETERMINISTIC -> BEGIN -> RETURN unix_timestamp(concat(year(now()), "-01-01 00:00:00")) + 24 * 3600 * (j-1) ; -> END It works ... but I need the result in UTC, and the server is in WET, so the result is not the expected one : select jour(65) ; +------------+ | jour(65) | +------------+ | 1173135600 | +------------+ If I use : set @@time_zone="+0:00"; select jour(65) ; +------------+ | jour(65) | +------------+ | 1173139200 | +------------+ this is the expected result. But users (me !) may forget to set the time_zone, so I try to put the instruction in the function, like this: CREATE FUNCTION jour (j integer ) RETURNS int(11) -> DETERMINISTIC -> BEGIN -> SET @@time_zone="+0:00"; -> RETURN unix_timestamp(concat(year(now()), "-01-01 00:00:00")) + 24 * 3600 * (j-1) ; -> END And now I get : select jour(65) ; ERROR 1146 (42S02): Table '.' doesn't exist Gasp ! Any idea of the problem, and how to fix of it ? TIA, -- Philippe Naudin |