You are here: Re: Sort after adding leading zero to date? « PHP Programming Language « IT news, forums, messages
Re: Sort after adding leading zero to date?

Posted by naixn on 12/08/06 00:22

GarryJones wrote :
> [...]

You can do your query like this :
SELECT
*, DATE(CONCAT('2007', ml_mna, '-', ml_dya)) AS thedate
FROM
ml_lopp
LEFT JOIN
scfmforening
ON
(scfmforening.scfmnum = ml_lopp.scfmnum)
LEFT JOIN
ml_tidplats
ON
(ml_tidplats.loppnum = ml_lopp.loppnum)
ORDER BY
thedate

This idea is to concatenate 2007, the month, and the day, then you get
2007-2-1 for the 1st of january, and the function :
DATE() receives it [ DATE('2007-2-1') ] and return :
2007-02-01
And this value is put in "thedate", which is used for the sorting ;)

Could you try and tell the result?

--
Naixn
http://fma-fr.net

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация