Oracle cannot find date for 1800's year

Oracle cannot find date for 1800's year

Post by sui.. » Sun, 08 Mar 1998 04:00:00



I know this is stupid but I have to ask the date problem. I am dealing
with a date field which value frange from 1800 to now. I do the following
code to change the date string 'YYYYMMDD' into a date:

v_priority_date := TO_DATE(substr(priority, 1, 8), 'YYYYMMDD');
v_priority_date_text := TO_CHAR(v_priority_date, 'DD-MON-YYYY');
v_priority_date := TO_DATE(v_priority_date_text, 'DD-MON-YYYY');
v_priority_date_text := TO_CHAR(v_priority_date, 'DD-MON-YY');
v_priority_date := TO_DATE(v_priority_date_text, 'DD-MON-YY');

Then I use the follwing select statement to search for the record:

        SELECT water_allocation_id
          INTO v_water_allocation_id
          FROM water_alloc_priorities
         WHERE priority_number_date = v_priority_date
           AND priority_number = v_priority_number;

It comes to my notice that some of records in the range 1889 - 1899 cannot
be pciked up the query. What's wrong?

I tried to use the compare statement like:

   WHERE TO_CHAR( priority_number_date, 'YYYYMMDD') = TO_CHAR(
v_priority_date, 'YYYYMMDD')

But it took 9 hours to run the job as Oracle will fo a full table scan
for each record is selected.

Please help.

--
Best regards,

 
 
 

Oracle cannot find date for 1800's year

Post by Steve Cosn » Sun, 08 Mar 1998 04:00:00




>I know this is stupid but I have to ask the date problem. I am dealing
>with a date field which value frange from 1800 to now. I do the following
>code to change the date string 'YYYYMMDD' into a date:

>v_priority_date := TO_DATE(substr(priority, 1, 8), 'YYYYMMDD');
>v_priority_date_text := TO_CHAR(v_priority_date, 'DD-MON-YYYY');
>v_priority_date := TO_DATE(v_priority_date_text, 'DD-MON-YYYY');
>v_priority_date_text := TO_CHAR(v_priority_date, 'DD-MON-YY');
>v_priority_date := TO_DATE(v_priority_date_text, 'DD-MON-YY');

In the above code, you should only use the first TO_DATE conversion.
The second is unnecessary, and the third is causing your problem.

When you do a TO_DATE and only include a 2-digit year, the system
assumes the century of the client or server where the commands are
running.  Since this is 1998, all your years get 19 for the century.
And guess what happens in 2000?

Steve Cosner
----------------------------------------------------------
http://members.aol.com/stevec5088
Downloadable utility form -- Display and update any table.

Quote:>Then I use the follwing select statement to search for the record:

>        SELECT water_allocation_id
>          INTO v_water_allocation_id
>          FROM water_alloc_priorities
>         WHERE priority_number_date = v_priority_date
>           AND priority_number = v_priority_number;

>It comes to my notice that some of records in the range 1889 - 1899 cannot
>be pciked up the query. What's wrong?

>I tried to use the compare statement like:

>   WHERE TO_CHAR( priority_number_date, 'YYYYMMDD') = TO_CHAR(
>v_priority_date, 'YYYYMMDD')

>But it took 9 hours to run the job as Oracle will fo a full table scan
>for each record is selected.


 
 
 

1. Oracle Reports REP-1800 Formatter Error

Hello,

I am running an Oracle Report from a commandline with rwrun60c against
a 8.0.6 Oracle DB and directing the output to a file.  Everytime I try
to do this, I get an REP-1800 error.  I have seen numerous posts on
usergroups and even Metalink about making sure to set a PRINTER env
variable which I have done with a valid printer that I am able to
print to with no change in error.  I can also duplicate this error
with other reports so it is not linked to just this one.  For testing
purposes, I have registered the report under Oracle Applications and
have let the Concurrent Manager run the report which was successful.
I can also run the report successfully from the Reports Designer
connecting as the same user as I am attempting to on the command line
run.  The problem seems to lie when I run it from the command line,
which is a requirement of this project.  Anyone have any ideas
concerning environment or anything in general that I am missing?

Thanks
Brent

2. Import of Oracle database with constraints into SQL server

3. Oracle Developer REP-1800 error

4. Formerly WORKING database no longer working - HELP???????

5. how to handle 1800 cubes in an Extranet?

6. Question

7. SQL 7.0 -- using over 1800 threads

8. ***Get 1800 FREE XXX Sites***

9. REP-1800: Formatter Error VGS-1313: Font Lookup Failed

10. SQL Question on Year 1900 's vs Year 2000's