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: MAX(DATE)

Re: MAX(DATE)

From: Sharkie <sharkie2_at_my-deja.com>
Date: Wed, 29 Mar 2000 19:45:33 GMT
Message-ID: <8btmgp$jj4$1@nnrp1.deja.com>


there might be different ways, but what I usually do when handling dates, I convert them to a char string, so in your case instead of:
SELECT MAX(timestamp)
you can try:
SELECT MAX(TO_CHAR(timestamp,'YYYYMMDDHH24MMSS'))

you can convert this string back to date later using TO_DATE function with same date format string.

note, this date format string will always work correct when comparing. Do NOT use the american date format MMDDYY, not MMDDYYYY since it will not always compare "right" (ie the biggest date should be the latest date).

In article <8btkgn$h7g$1_at_nnrp1.deja.com>, jeanch_at_my-deja.com wrote:
> Folks
>
> Can anybody help ?
>
> I am trying to get the latest (timewise) entry to the clipboard.
>
> when I run the below select using SQL it works
> but not using PL/SQL;
>
> It seems like the MAX function does not
> understand Date type.
>
> ....
> v_undoString CLIPBOARD.DATA%TYPE DEFAULT NULL;
> p_eid INTEGER;
> v_name VARCHAR(30);
>
> BEGIN
> SELECT data
> INTO v_undoString
> FROM CLIPBOARD WHERE
> timestamp = (SELECT MAX(timestamp)
> FROM CM_UNDO_CLIPBOARD
> WHERE num = p_num AND OWNER = v_Name);
> END;
>
> Table description
> Name Null? Type
> ------------------------------- -------- ----
> num NUMBER(38)
> TIMESTAMP DATE
> OWNER VARCHAR2(100)
> DATA VARCHAR2(2000)
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
>

--
If the human brain were so simple
that we could understand it,
we would be so simple we couldn't.
-Makes Sense... don't it?

Sent via Deja.com http://www.deja.com/
Before you buy. Received on Wed Mar 29 2000 - 13:45:33 CST

Original text of this message

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