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: SQL : where clause to include data for the previous 24 hours

RE: SQL : where clause to include data for the previous 24 hours

From: Glenn Travis <Glenn.Travis_at_sas.com>
Date: Tue, 09 Apr 2002 07:48:23 -0800
Message-ID: <F001.0043F756.20020409074823@fatcity.com>


or (sysdate - 18/24)

> -----Original Message-----
> From: Mercadante, Thomas F [mailto:NDATFM_at_labor.state.ny.us]
> Sent: Tuesday, April 09, 2002 9:08 AM
> To: Multiple recipients of list ORACLE-L
> Subject: RE: SQL : where clause to include data for the previous 24
> hours
>
>
> Johan,
>
> There is no need to convert sysdate to a string and back to a
> data. I'm not
> sure what you mean by "calculate the previous 24 hours when
> a query is run
> and bump the time by 6 hours".
>
> It looks like you are trying to retrieve all records that
> have a date/time
> within the last 18 hours - is this correct? if so, then your
> query would
> be:
>
> where event_date > (sysdate + 6/24) - 1
>
> The default date format really has nothing to do with how the
> dates are
> stored within the database - they are all stored the same
> way. This means
> you can do simple date math like above.
>
> Hope this is what you are looking for.
>
> Tom Mercadante
> Oracle Certified Professional
>
>
> -----Original Message-----
> Sent: Tuesday, April 09, 2002 8:13 AM
> To: Multiple recipients of list ORACLE-L
>
>
> I need a where clause to ACCURATELY (down to the second) calculate the
> previous 24 hours when a query is run and bump the time by 6 hours
> (event_date is based on GMT). The default date format has been set to
> 'SYYYY-MM-DD HH24:MI:SS','NLS_CALENDAR=GREGORIAN'.
>
> I've tried the following:
>
> " where event_date >
> (to_date(substr(sysdate,0,22),'YYYY/MM/DD HH24:MI:SS')
> + 6/24) - 1".
>
> Any ideas?
>
> --
> Please see the official ORACLE-L FAQ: http://www.orafaq.com
> --
> Author: Johan Muller
> INET: c-johan.muller_at_wcom.com
>
> Fat City Network Services -- (858) 538-5051 FAX: (858) 538-5051
> San Diego, California -- Public Internet access / Mailing Lists
> --------------------------------------------------------------------
> To REMOVE yourself from this mailing list, send an E-Mail message
> to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
> the message BODY, include a line containing: UNSUB ORACLE-L
> (or the name of mailing list you want to be removed from). You may
> also send the HELP command for other information (like subscribing).
> --
> Please see the official ORACLE-L FAQ: http://www.orafaq.com
> --
> Author: Mercadante, Thomas F
> INET: NDATFM_at_labor.state.ny.us
>
> Fat City Network Services -- (858) 538-5051 FAX: (858) 538-5051
> San Diego, California -- Public Internet access / Mailing Lists
> --------------------------------------------------------------------
> To REMOVE yourself from this mailing list, send an E-Mail message
> to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
> the message BODY, include a line containing: UNSUB ORACLE-L
> (or the name of mailing list you want to be removed from). You may
> also send the HELP command for other information (like subscribing).
>

-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.com
-- 
Author: Glenn Travis
  INET: Glenn.Travis_at_sas.com

Fat City Network Services    -- (858) 538-5051  FAX: (858) 538-5051
San Diego, California        -- Public Internet access / Mailing Lists
--------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).
Received on Tue Apr 09 2002 - 10:48:23 CDT

Original text of this message

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