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

Home -> Community -> Usenet -> c.d.o.misc -> Re: Client and Server SQL statements work differently??

Re: Client and Server SQL statements work differently??

From: Arjan van Bentem <avbentem_at_DONT-YOU-DAREdds.nl>
Date: Thu, 6 Aug 1998 20:26:14 +0200
Message-ID: <6qcsfl$dsu$1@newton.a2000.nl>


>Is it something like
> where sampledate <= To_date('31-12-98')

No, you have to supply the date format. Oracle does not store dates as strings, but as some kind of numeric value, containing both date and time.

In

    SELECT *
    FROM psms_db.down_hist
    WHERE datestamp > '06-Aug-1998 00:00:00'

you do not use to_date. But the column datestamp has been defined as a date column. To be able to compare a date to a string, Oracle will first convert the string to a date, using the default date format. Also, Oracle uses that default date format when you use to_date(..) but do not specify the date format. You can see what your default date format is by:

    select sysdate
    from dual;

Here, no to_char(..) is explicitly specified, but Oracle will implicitly convert sysdate to a string anyway, using the default date format. So, you will have to use:

    SELECT *
    FROM psms_db.down_hist
    WHERE datestamp > to_date( '06-Aug-1998 00:00:00', 'DD-Mon-YYYY HH24:MI:SS' );

or, when the time part is 00:00:00

    WHERE datestamp > to_date( '06-Aug-1998', 'DD-Mon-YYYY' );

Arjan. Received on Thu Aug 06 1998 - 13:26:14 CDT

Original text of this message

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