Re: SQL Order by Date `Date` column

Tech-Archive recommends: Fix windows errors by optimizing your registry




"Al Reid" <areidjr@xxxxxxxxxxxxxxxx> wrote in message
news:O#O11ruNFHA.2604@xxxxxxxxxxxxxxxxxxxxxxx
> "Edward Boquette" <uwhat@xxxxxxxxxxxxxx> wrote in message
news:tog3e.6914311$f47.1268526@xxxxxxxxxxxxxxxxxxxx
> > Hi
> >
> > I am having problems with my SQL in which i want it to return to me all
the
> > records in date order desc.
> >
> > The code i am using now is :-
> >
> > sSQL = "Select * from TABLE1 where comments & followcoms & event_ID like
'%"
> > & Text2.Text & "%' ORDER BY date " & (" ASC")
> >
>
> You stated you wanted them in date order descending, but your SQL shoes
ASC.
>
> > It currently only returns date in the order of e.g
> >
> > 01/01/05
> > 01/02/05
> > 02/01/05
> >
>
> This looks like it is properly ordered (in ascending order)
>
> Jan 1, 2005
> Jan 2, 2005
> Feb 1, 2005
>
> > but i would like the dates returned correctly in order, not by numeric
> > order.
> >
> > Currently the field name in the DB is called date, and formatted to
dd/mm/yy
> > so thats why i cant work this out!
> >
>
> Is it stored in the database as a Date datatype?
>
> perhaps you can try "...ORDER BY CONVERT(char(12), date , 3)" if you are
using MSSQL. In Oracle it would be the TO_CHAR function
> and in MSAccess, I believe you can use the Format function.
>
>
> > Many thanks for your help.
> >
> > Ed
> >
> >
> >
>


Sorry All !!

I know i wrote desc, but i do want ASC as per the code says!!

Any ideas?

Many Thanks !!




.



Relevant Pages

  • Re: strange BLOB beahaviour
    ... ASC, ... plan A is without "Picture is not null" and plan B is with that statement. ... and and the preferred data type in SQL 2005 and later is varbinary. ...
    (microsoft.public.sqlserver.server)
  • Re: strange BLOB beahaviour
    ... ASC, ... plan A is without "Picture is not null" and plan B is with that statement. ... and and the preferred data type in SQL 2005 and later is varbinary. ...
    (microsoft.public.sqlserver.server)
  • Re: strange BLOB beahaviour
    ... After i removed "Pictures ... Even better would be to see the query plans for the two cases. ... Links for SQL Server Books Online: ... ASC, ...
    (microsoft.public.sqlserver.server)
  • Re: foreign key references only part of composite PK - table scan issue
    ... there is only 1 join with 3 tables at play, ... Links for SQL Server Books Online: ... FROM ABC_Staging.dbo.Stage_ABC_ContactKey AS A WITH (NOLOCK) ... ASC ...
    (comp.databases.ms-sqlserver)
  • Re: Data Type Mismatch - String versus Long
    ... The problem is your SQL is not correctly formed. ... "ORDER BY lngOrderID ASC;" ... I am trying to build a WHERE clause with numeric criteria and storing it ... ' Create the WHERE clause criteria. ...
    (microsoft.public.access.modulesdaovba)