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: Last date

Re: Last date

From: David Smith <skandor_at_worldnet.att.net>
Date: Wed, 5 May 1999 09:23:21 -0500
Message-ID: <7gpk62$5vp$1@bgtnsc01.worldnet.att.net>


Couple of ways,

One, yes make it a date.
 or Two, Create a stored database function that you pass in the text item and it passes back the date. Placing it in a package is also a good idea.

create or replace package misc_utils is   text_to_date(p_text in varchar2) return date;   pragma restrict_references(text_to_date,'WNDS','WNPS'); -- needed to have access in sql
end misc_utils;
/

create or replace package body misc_utils is   function text_to_date (p_text in varchar2) return date is     l_date date;
  begin

      l_date := to_date(p_text,'your format here');
     return l_date;

  exception
  when others then
      l_date := null;
     return l_date;

  end text_to_date;
end misc_utils;
/

Once created, you can then use it in the order clause of your select statement
e.g.
order by misc_utils.text_to_date('your column') desc;

Peter Michael Bager wrote in message <37303C77.1E2AB4F2_at_knold.ballehs.dk>...
>We are a couple of guys who's having some problems with our Oracle
>database.
>We have been asked to make a financial program for a restaurant.
>The problem is about the date funcion in Oracle, we want the program to
>find the last record in the database, using the date as search. But the
>problem is that the last record the database finds is the ones who have
>been inserted on a Wednesday, probably because the W is the last letter
>in the alphabet. We have made the field with the date as a text item.
>What should we do???
>should we change the date field from a text item to a date item?????
>or is there a way to program you out of our current problem?????
>
>We hope that some of you have the solution to our problem
>
>
>
Received on Wed May 05 1999 - 09:23:21 CDT

Original text of this message

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