List:General Discussion« Previous MessageNext Message »
From:James Nobis Date:April 12 2005 2:19pm
Subject:avg and timestamp/datetime
View as plain text  
Hi all,

Essentially I was asked to look into a problem with a query at the office which
used AVG on a datetime column which produces incorrect results.  (MySQL 4.1.10
on RHEL 3 update 4)  As you can see below the stark difference between the
correct and incorrect results.  Though, the incorrect result has the correct
year (this seems actually to be coincidence and nothing more) but I am not sure
exactly what MySQL did for casting.  The query produces no errors or warnings. 
I *think* the incorrect result is an "internal" timestamp format but with the
wrong data.  Is there a part of the manual that I missed which explains this
unexpected behavior?

AVG(col) v FROM_UNIXTIME(AVG(UNIX_TIMESTAMP(col)))
20050258324839 v 2005-03-24 02:05:11

James Nobis
Web Developer
Academic Superstore
223 W. Anderson Ln. Suite A110, Austin, TX 78752
Voice: (512) 450-1199 x453 Fax: (512) 450-0263
http://www.academicsuperstore.com

----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.
Thread
avg and timestamp/datetimeJames Nobis12 Apr
  • Re: avg and timestamp/datetimeSGreen12 Apr
    • Re: avg and timestamp/datetimeJames Nobis12 Apr
      • Re: avg and timestamp/datetimeSGreen12 Apr