Xref: alice comp.databases.oracle.misc:30525
Path: alice!news-feed.fnsi.net!netnews.com!europa.netcrusader.net!204.127.161.3!wn3feed!worldnet.att.net!wnmaster2!not-for-mail
From: "David Smith" <skandor@worldnet.att.net>
Newsgroups: comp.databases.oracle.misc
Subject: Re: Last date
Date: Wed, 5 May 1999 09:23:21 -0500
Organization: Mezzanine Enterprises
Lines: 52
Message-ID: <7gpk62$5vp$1@bgtnsc01.worldnet.att.net>
References: <37303C77.1E2AB4F2@knold.ballehs.dk>
Reply-To: "David Smith" <skandor1@bigfoot.com>
X-Trace: bgtnsc01.worldnet.att.net 925914114 6137 12.74.100.35 (5 May 1999 14:21:54 GMT)
X-Complaints-To: abuse@worldnet.att.net
NNTP-Posting-Date: 5 May 1999 14:21:54 GMT
X-Newsreader: Microsoft Outlook Express 4.72.3110.1
X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.3

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@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
>
>
>


