Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> Re: Date comparison

Re: Date comparison

From: Stephane Faroult <sfaroult_at_roughsea.com>
Date: Mon, 12 Sep 2005 13:05:53 +0200
Message-ID: <43256111.2000209@roughsea.com>


This probably needs some qualifying. Whenever you convert a string to a date, use an explicit conversion and an explicit format. The default format can be changed without notice in the init.ora file. It can also be changed on the client side. Note also that there is a strong relationship between date format and language, so you should also be explicit about the language that you are using as well (a typical example is a test for "sunday". to_char('11-SEP-2005', 'DAY') will not return 'SUNDAY' if the language is anything else than English, so your to_char should include a third parameter to force the language).

Concerning TRUNC(), always apply it to constants, never to columns if you have any consideration for your indexes.

Stephane Faroult

David Sharples wrote:

> yes, compare dates to date and you can;t go wrong. If you just want
> the date part use trunc()
>
> On 9/12/05, *manoj.gurnani_at_polaris.co.in
> <mailto:manoj.gurnani_at_polaris.co.in>* <manoj.gurnani_at_polaris.co.in
> <mailto:manoj.gurnani_at_polaris.co.in>> wrote:
>
>
>
>
>
>
> Hi All,
> I've a date column in a oracle db table which stores
> date and
> time values.
> Is it advisable to use a date variable directly in a comparison
> with a date
> column
> without any formatting or using any other conversion functions like
> to_char.
>
>

--
http://www.freelists.org/webpage/oracle-l
Received on Mon Sep 12 2005 - 06:07:52 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US