hi

SELECT DATE_FORMAT(date_field ,"%M %D %Y")
             FROM table1
ORDER BY date_field

will order in true chronological order 

Peter



> -----Original Message-----
> From: David Blomstrom [mailto:[EMAIL PROTECTED]
> Sent: 22 June 2004 10:17
> To: [EMAIL PROTECTED]
> Subject: RE: New to Dates - Plain English Please
> 
> 
> --- Peter Lovatt <[EMAIL PROTECTED]> wrote:
> > Hi
> > 
> > There are two aspects to dates, and your questions
> > include parts of both.
> > 
> > When MySql stores dates you have a choice of column
> > types
> > 
> > http://dev.mysql.com/doc/mysql/en/DATETIME.html
> > 
> > has the details
> > 
> > If you just need to store dates then the DATE type
> > will suit your needs. You
> > just specify it as DATE
> > 
> > When you insert dates you need to insert them in the
> > format yyyy-mm-dd ie
> > 2004-12-31
> > 
> > When you retrieve them they default to the same
> > format.
> > 
> > If you wanted to retrieve them in a different format
> > that is when you use
> > DATE_FORMAT(date,format)
> > 
> > eg
> > 
> > INSERT  INTO table1
> >     (
> >     field1
> >     , date_field
> >     , field2
> >     )
> > VALUES
> >     (
> >     "some data"
> >     , "2004-02-12"
> >     , "some more data"
> >     );
> > 
> > 
> > then to retrieve the data
> > 
> > SELECT DATE_FORMAT(date_field ,"%M %D %Y")
> >             FROM table1
> > 
> > would return "February 12th 2004" instead of
> > "2004-02-12"
> > 
> > Hope this clarifies it......
> > 
> > Come back to me if not
> 
> Can you also print out your dates as February 12th,
> 2004, but order them by 2004-12-08? In other words,
> can you order dates chronologically, even though March
> comes before August alphabetically?
> 
> Thanks.
> 
> 
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around 
> http://mail.yahoo.com 
> 
> -- 
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to