Re: How can I compare a date in SQL?

From: Jim Kennedy <kennedy-family_at_attbi.com>
Date: Sun, 20 Oct 2002 03:54:57 GMT
Message-ID: <lOps9.21553$La5.57983_at_rwcrnsc52.ops.asp.att.net>


No it is not. This is a bad practice. While it is true that a lot of people set their nls_date format that way, it is easy to ahve it set differently. Don't compare dates and strings. Compare dates and dates. eg
Select * from Order where start_date >=to_date( '01-JAN-02' ,'dd-mmm-yyyy')

Assuming the string format is going to work is just asking for all sorts of problems and trouble down the road.
Jim

"benson wong" <benwong_at_tummytech.com> wrote in message news:66e3ruo6q2ajv36kl1qluv109viatt6eca_at_4ax.com...
> The default date format for Oracle is DD-MON-YY,
>
> so
>
> Select * from Order where start_date >= '01-JAN-02'
>
> should work.
>
>
> >Hi
> >
> >I am a newbie to Oracle. I really need someone to help me.
> >I got a SQL statement which try to select all the records with
> >start_date >= 01-Jan-2001 from a table in Oracle.
> >However, I do not know the exact format of the SQL statement.
> >My SQL statement is list as below
> >
> >Select * from Order where start_date >= 01-01-2001
> >
> >However, it did not work.
> >I have been searching the Web for article to help, however, I could not
> >find anything.
> >
> >Please help.
> >
> >Best regards
> >David Lau
>
Received on Sun Oct 20 2002 - 05:54:57 CEST

Original text of this message