Tom Crimmins wrote:
On Wednesday, April 13, 2005 20:17, [EMAIL PROTECTED] wrote:
MySql vers 4.0.20
A table "noticeboard" has three test entries.
A unix time from date("U") is stored in the field "published" of
type, bigint20.
I am not able to workout how to select the year. Assuming that the
value from date("U") can be treated as a unixtime value, my latest
unsuccessful effort is ....
$yearslist = mysql_query("SELECT published,
FROM_UNIXTIME(UNIX_TIMESTAMP(published),'%Y') AS year FROM
noticeboard") or die("Cannot get list of years.<br>" .
mysql_error());
My guess is that you are passing what is already a unix timestamp to
the function unix_timestamp, and since that is an invalid datetime it
returns zero which then causes from_unixtime to return 1969 (when epoch
time started in your time zone).
Try using FROM_UNIXTIME(published,'%Y')
I saw my mistake as soon as I posted and it was as you say. Many thanks
Louise
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]