PJ
|
| Posted: 03/12/2002, 10:33 AM |
|
Can anyone advise.
I am using the following in a SQL statement: DATE_FORMAT(datefield1, '%d %M
%Y')AS datefield1 ORDER BY datefield1 Desc
The problem I appear to have is that the sort is taking place on the 'day'
rather than the whole date. In other words 30 March 2002 is appearing
before 28 February 2002 which is before 26 April 2002 rather than the
calendar date.
How can I sort this field correctly?
|
|
|
 |
Roger McIlmoyle
|
| Posted: 03/12/2002, 1:14 PM |
|
change your sql statement to"
DATE_FORMAT(.....) as datefield1f ...... order by datefield1
The problem is your current statemend alters the field essentially to type
char, hence the alphabeticaly sort.
"PJ" <apis@globalnet.co.uk> wrote in message
news:a6lhl4$80d$1@news.codecharge.com...
> Can anyone advise.
>
> I am using the following in a SQL statement: DATE_FORMAT(datefield1, '%d
%M
> %Y')AS datefield1 ORDER BY datefield1 Desc
>
> The problem I appear to have is that the sort is taking place on the 'day'
> rather than the whole date. In other words 30 March 2002 is appearing
> before 28 February 2002 which is before 26 April 2002 rather than the
> calendar date.
>
> How can I sort this field correctly?
>
>
|
|
|
 |
PJ
|
| Posted: 03/13/2002, 11:19 AM |
|
Unfortunately, I can't understand what you are suggesting but I realise the
problem now! DATE_FORMAT produces a string!
"Roger McIlmoyle" <rmcilmyl@idirect.com> wrote in message
news:a6lr3n$pgr$1@news.codecharge.com...
> change your sql statement to"
>
> DATE_FORMAT(.....) as datefield1f ...... order by datefield1
>
> The problem is your current statemend alters the field essentially to type
> char, hence the alphabeticaly sort.
>
> "PJ" <apis@globalnet.co.uk> wrote in message
>news:a6lhl4$80d$1@news.codecharge.com...
> > Can anyone advise.
> >
> > I am using the following in a SQL statement: DATE_FORMAT(datefield1, '%d
> %M
> > %Y')AS datefield1 ORDER BY datefield1 Desc
> >
> > The problem I appear to have is that the sort is taking place on the
'day'
> > rather than the whole date. In other words 30 March 2002 is appearing
> > before 28 February 2002 which is before 26 April 2002 rather than the
> > calendar date.
> >
> > How can I sort this field correctly?
> >
> >
>
>
|
|
|
 |
|