Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: oracle date
Hi Randall,
since you say your data file contains two fields which doesn't have an associated
data type,
programmatically, you should put the second column into a Java date/calendar type to
ensure
that it really is a date. You would use the DateFormat class to accomplish this.
Since your second string will sometimes contain a time portion and
sometimes not, this will solve your formatting problem. You will use the to_date
call to insert, but you will
always know your date format because whatever you threw into the the java date field
will have
either initialized the time portion, or it will default it to 0 hours, 0 minutes, 0
seconds, so when
you pull it back out of the java date type, pull it out it with the hour, minutes,
seconds.
This will solve your problem from a java point of view.
Hope this helps,
Cindy
"Randall J. Parr" wrote:
> Thomas Kyte wrote:
>
> > ,,,,,,,,,,,,,,,,,,,,,
>
> Any suggestions on how to set the NLS_DATE_FORMAT or otherwise fix the following
> problem?
>
> I am trying to insert records with dates which may or may not include
> the time portion of the date. I am reading these records from a text
> file using Java and performing the inserts with JDBC.
>
> For exmple A) '07/02/1990' or B) '07/02/1999 00:00:00'
>
> With NLS_DATE_FORMAT set to 'MM/DD/RRRR' date B gives an error (more or
> less) "ran out of date format before finished".
>
> With NLS_DATE_FORMAT set to 'MM/DD/RRRR HH24:MI:SS' date A gives and
> error (more or less) "incomplete date"
>
> Is there a way to set a date format (preferably a default format) such
> that the time portion of the date is optional?
>
> I am trying to avoid solutions which include wrapping the date to be
> inserted in JDBC escapes and/or TO_DATE( mydate, 'myformat') because I
> only have column name and column data in the text file (that is, the
> text file doesn't contain any information about the column types).
>
> Thanks
> R.Parr
> Temporal Arts
Received on Sun Aug 08 1999 - 23:25:04 CDT