Bluehost.com Web Hosting $6.95

time_zone and ERROR 1146 Table '.' doesn't exist

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 ...


Go Back   Usenet Forums > Database Forums > MySQL Database

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 03-06-2007
Philippe Naudin
 
Posts: n/a
Default time_zone and ERROR 1146 Table '.' doesn't exist

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
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 04:09 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0