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: Help with date query

Re: Help with date query

From: Problematic coder <gnewsham_at_gmail.com>
Date: 8 May 2007 12:26:26 -0700
Message-ID: <1178652386.656826.249980@e51g2000hsg.googlegroups.com>


On May 7, 5:02 pm, Geoff Muldoon <geoff.muld..._at_trap.gmail.com> wrote:
> Problematic coder says...
>
> > I decided it would be fine to select .... where entry_date =
> > max(entry_date) since there will always be entries on every business
> > day, the only problem with this is if this query is run today after an
> > entry has already been made today, then it will return a result set
> > for today and not the last business day. If we worked everyday it
> > would be easy to do: where entry_date = (sysdate - 1) but since we do
> > not work weekends or holidays this would not work
>
> > It seems like I need to write something like this sudo code but I am
> > not sure how
>
> > select * from mytable where entry_date is the max entry_date other
> > than sysdate
>
> For that pseudo-code, a simple subquery.
>
> select * from mytable where entry_date = (select max(entry_date) from
> mytable where entry_date <> sysdate)
>
> Depending on the storage format of entry_date you may need to use
> trunc(entry_date) <> trunc(sysdate)
> to ignore time components.
>
> GM

Thank you, exactly what I needed Received on Tue May 08 2007 - 14:26:26 CDT

Original text of this message

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