Skip to main content
Inspiring
September 24, 2006
Question

date order problem

  • September 24, 2006
  • 3 replies
  • 216 views
Hi

I am trying to order a couple dates and i have no idea why this is not
working


SQL Statement
rs_events_cmd.CommandText = "SELECT * FROM events ORDER BY fromdate ASC"

Here are the dates from the database

fromdate
9/9/2006
9/16/2006
10/14/2006
10/21/2006
11/3/2006
9/22/2006
11/11/2006
11/12/2006


The order they show up on the page is kinda strange

10/14/2006
10/21/2006
11/11/2006
11/12/2006
11/3/2006
9/16/2006
9/22/2006
9/9/2006

Any help would be greatly appreciate.

Thanks


This topic has been closed for replies.

3 replies

Inspiring
September 24, 2006
Thanks guys



Inspiring
September 24, 2006
On 24 Sep 2006 in macromedia.dreamweaver.appdev, Peter wrote:

> I am trying to order a couple dates and i have no idea why this is
> not working
>
> SQL Statement
> rs_events_cmd.CommandText = "SELECT * FROM events ORDER BY fromdate
> ASC"
>
> Here are the dates from the database
>
> fromdate
> 9/9/2006
> 9/16/2006
> 10/14/2006
> 10/21/2006
> 11/3/2006
> 9/22/2006
> 11/11/2006
> 11/12/2006
>
>
> The order they show up on the page is kinda strange
>
> 10/14/2006
> 10/21/2006
> 11/11/2006
> 11/12/2006
> 11/3/2006
> 9/16/2006
> 9/22/2006
> 9/9/2006
>
> Any help would be greatly appreciate.

You don't say what kind of database it is. You also don't say what
kind of field you've entered the date into, but if it's anything other
than some sort of date field, then it's sorted correctly.

MySQL, for example, stores dates as yyyymmdd; formatting them on output
is relatively easy and is left for you, the database programmer.
Access and SQL Server are similar.

--
Joe Makowiec
http://makowiec.net/
Email: http://makowiec.net/email.php
Inspiring
September 24, 2006
Peter wrote:
> I am trying to order a couple dates and i have no idea why this is not
> working

Judging from your date format, it looks as though you're working with
Access, which permits you to insert dates in a variety of formats. The
sort order is numerical, rather than date order. I'm not very familiar
with the data types in Access, but it looks as though you haven't
defined the correct data type for the column.

--
David Powers
Adobe Community Expert
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
http://foundationphp.com/