Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Help with date query
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 Received on Mon May 07 2007 - 19:02:51 CDT
![]() |
![]() |