MySql query displays wrong time, but date is right -


after long search found script looking for. works fine. 1 aspect works wrong: date , time. should receive

5   2014-02-24 14:59:28     7   null     5   2014-02-24 15:32:55     6   -1   5   2014-03-08 10:32:19     60  54   5   2014-03-08 10:40:23     20  -40      5   2014-03-08 10:44:22     21  1    5   2014-03-08 15:05:54     2   -19      5   2014-03-08 15:06:10     25  23   

but got:

5   2014-02-24 02:59:28     7   null    null 5   2014-02-24 03:32:55     6   -1  -14.2857% 5   2014-03-08 03:05:54     2   -19     -90.4762% 5   2014-03-08 03:06:10     25  23  1150.0000% 5   2014-03-08 10:32:19     60  54  900.0000% 5   2014-03-08 10:40:23     20  -40     -66.6667% 5   2014-03-08 10:44:22     21  1   5.0000% 

this example stock_id 5. others wrong time, too. code following:

select stock_id,date_format(date,'%y-%m-%d %h:%i:%s') date , price,pxchange,concat(round(pxpct*100,4),'%') pxpct (select       case when stock_id <> @pxticker           @pxclose := null end,     p.*,     (price-@pxclose) pxchange,     (price-@pxclose)/@pxclose pxpct,     (@pxclose := price),     (@pxticker := stock_id)   quotations p   cross join   (  select       @pxclose := null,      @pxticker := stock_id      quotations       order stock_id, date limit 1)    order stock_id, date ) b order stock_id, date asc 

but went wrong? added (date,'%y-%m-%d %h:%i:%s') right, didn't? idea problem is?


edit - additional question , code

select  stock_id, stocks.name, date_format( date, '%y-%m-%d %h:%i:%s' ) date,  price,  pxchange,  concat( round( pxpct *100, 4 ) , '%' ) pxpct,  stocks.stockmarket,  stockmarkets.id  ( select case when stock_id <> @pxticker @pxclose := null end , p . * ,  (price - @pxclose) pxchange,  (price - @pxclose) / @pxclose pxpct,  (@pxclose := price),  (@pxticker := stock_id)  quotations p  cross join  ( select @pxclose := null , @pxticker := stock_id quotations order stock_id, date limit 1 ) order stock_id, date ) b   left join  stocks on stock_id = stocks.id left join stockmarkets on stockmarkets.id = stocks.stockmarket  stocks.stockmarket = (select id stockmarkets short ='nasdaq') group stock_id order stock_id, min(date) asc 

the date function needs uppercase h output in 24 hour format, otherwise output am/pm date, without am/pm symbols (i.e. hour 0-11).


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -