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

Home -> Community -> Usenet -> c.d.o.server -> Re: Date calculation when a closed day occure, loop back 1 day until the day is open

Re: Date calculation when a closed day occure, loop back 1 day until the day is open

From: andrewst <member14183_at_dbforums.com>
Date: Wed, 21 May 2003 14:38:25 +0000
Message-ID: <2906298.1053527905@dbforums.com>

Originally posted by Xavier
> Hi there,
>
> I need a sample code for doing this (newbie to Oracle... Sorry ;)
>
> This is the pseudo code problem (since I dunno how to put that in a
> Oracle SQL):
>
> _______________________________________________________________
> date_to_check = (today - 1 day);
>
> loop while (day_to_check) != closed
> {
> date_to_check = (date_to_check - 1 day);
> }
> _______________________________________________________________
>
> I'm supposed to put that in a SELECT Statement because I have to play
> in a strange DB that needs to do a realtime calculation for percent
> between 2 dates values in the same table with more than 1'000'000
> records... The stranger thing is that theses data can be
> pre-calculated but they don't want the DB to be modified....H E L P
> P L Z
>
> Thanx in Advance,
>
> Xavier

Sounds like you want something like:

SELECT MAX(date_col)
FROM table
WHERE date_col < SYSDATE
AND status = 'CLOSED';

--
Posted via http://dbforums.com
Received on Wed May 21 2003 - 09:38:25 CDT

Original text of this message

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