Welcome to MobyThreads.com!
FAQFAQ      ProfileProfile    Private MessagesPrivate Messages   Log inLog in
All support for the MobyThreads Threaded phpBB MOD can now be found on welsolutions at this forum

date ORDER BY

 
   Web Hosting and Web Master Forums (Home) -> Webmaster RSS
Next:  Why is my site slow? What is the bottleneck??  
Author Message
admin8

External


Since: Jul 14, 2003
Posts: 10



(Msg. 1) Posted: Mon Jul 14, 2003 12:19 pm
Post subject: date ORDER BY
Archived from groups: alt>www>webmaster (more info?)

Hi,

I'm currently running a sql select statement on a date field which is
ordered by the date field in ascending order. It worked fine for the 1st to
the 9th of the month but when it output 10th, 11th, 12th etc. it put them
before the 1st. So I was getting:

10th
11th
12th
1st
2nd
.....

my query is:

$totalquery = "SELECT click, search, shop, DATE_FORMAT(date, '%D %b, %Y') AS
date FROM donation_totals ORDER BY date ASC LIMIT 7"

Any ideas why this is happening?

Thanks,

Adi

 >> Stay informed about: date ORDER BY 
Back to top
Login to vote
sp_bhuisman

External


Since: Jun 27, 2003
Posts: 571



(Msg. 2) Posted: Mon Jul 14, 2003 12:22 pm
Post subject: Re: date ORDER BY [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

On Mon, 14 Jul 2003 09:19:09 +0100, Adi <admin RemoveThis @NOSPAMadigaskell.org> wrote:

 > Hi,
 >
 > I'm currently running a sql select statement on a date field which is
 > ordered by the date field in ascending order. It worked fine for the 1st
 > to
 > the 9th of the month but when it output 10th, 11th, 12th etc. it put them
 > before the 1st. So I was getting:
 >
 > 10th
 > 11th
 > 12th
 > 1st
 > 2nd
 > ....
 >
 > my query is:
 >
 > $totalquery = "SELECT click, search, shop, DATE_FORMAT(date, '%D %b, %Y')
 > AS
 > date FROM donation_totals ORDER BY date ASC LIMIT 7"
 >
 > Any ideas why this is happening?

Try:

$totalquery = "SELECT click, search, shop, DATE_FORMAT(date, '%D %b, %Y')
AS date FROM donation_totals ORDER BY CAST(date AS UNSIGNED) ASC LIMIT 7"

* not tested.

Grey

--
The technical axiom that nothing is impossible sinisterly implies the
pitfall corollory that nothing is ridiculous.
- <a style='text-decoration: underline;' href="http://www.greywyvern.com" target="_blank">http://www.greywyvern.com</a> - Orca RingMaker: PHP web ring creation and
management<!-- ~MESSAGE_AFTER~ -->

 >> Stay informed about: date ORDER BY 
Back to top
Login to vote
ruzun

External


Since: Jul 14, 2003
Posts: 5



(Msg. 3) Posted: Mon Jul 14, 2003 3:15 pm
Post subject: Re: date ORDER BY [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

 > $totalquery = "SELECT click, search, shop, DATE_FORMAT(date, '%D %b, %Y')
AS
 > date FROM donation_totals ORDER BY date ASC LIMIT 7"
 >
 > Any ideas why this is happening?

My Solution : to add dates for later ordering i configure a orderid in my
Tables
$updtime = strftime("%H%M%S");

$upddate = date("Ymd");

$orderid = "$upddate$updtime";

so i can use this for best select and order options : ORDER by orderid
DESC...<!-- ~MESSAGE_AFTER~ -->
 >> Stay informed about: date ORDER BY 
Back to top
Login to vote
noonehere

External


Since: Jul 10, 2003
Posts: 7



(Msg. 4) Posted: Mon Jul 14, 2003 5:38 pm
Post subject: Re: date ORDER BY [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

On Mon, 14 Jul 2003 09:19:09 +0100, "Adi" <admin.TakeThisOut@NOSPAMadigaskell.org>
wrote:

 >Hi,
 >
 >I'm currently running a sql select statement on a date field which is
 >ordered by the date field in ascending order. It worked fine for the 1st to
 >the 9th of the month but when it output 10th, 11th, 12th etc. it put them
 >before the 1st. So I was getting:

Is it a "real" date field in the d/b or just a text field with a
date in it ?

This is a classic sorting issue with a non-zero filled alpha sort
of alpha data being treated as numeric. The solution is often
to run an update to the datebase and zero fill the single
digit dates, then make sure the program that writes new records
does that in the future.

Bob<!-- ~MESSAGE_AFTER~ -->
 >> Stay informed about: date ORDER BY 
Back to top
Login to vote
Display posts from previous:   
Related Topics:
Order forms - I've been trying ... with little success ... to create an order form, listing various products c/w prices to include on my site. Does anyone know of any forms (which can be customized) available on the web ? TIA, David

Accessibility - "Logical tab order...." - Doing some accessibility checking on one of my sites, I'm down to this warning for my main nav setup: [WCAG-AAA/Low] Create keyboard shortcuts and/or a logical tab order between controls. The issue, to me, is there's no reliable way to implement..
   Web Hosting and Web Master Forums (Home) -> Webmaster All times are: Pacific Time (US & Canada) (change)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]