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: Using date format in Oracle??

Re: Using date format in Oracle??

From: Graham Miller <lgmiller_at_elmrd.u-net.com>
Date: 1997/06/15
Message-ID: <33a4bd86.4578657@news.u-net.com>#1/1

hello,
  You don't specify the circumstances or products you want to use the date columns in. However, and briefly:

You can use date columns directly in queries and any dml statements.

They not only contain a day (year, month, day) but a time as well. This needs to be remembers when comparing date columns. The 'trunc' function will lose the time portion.

Date columns cannot be added together (it is meaningless) but can be subtracted. A number of days (or fractions of a day) can be added or subtracted to a date column.

There is a default date format defined for Oracle and any character string assigning a date to a column will use the default format. You can always use the 'to_date' function to specify the format.

Formats:
  There are dozens of date formats, i suggest looking at the manual.

To convert a character string to a date use the 'to_date' function and to convert a date (or portion ) to a string use the 'to_char' function.

Some examples:

to show date and time:

   to_char( sysdate, 'DD-MM-YYYY HH24:MI:SS')

note: MM for months, MI for minutes.

to convert '28/02/1997' to a date:

  to_date('28/02/1997', 'DD/MM/YYYY')

the time part will be set to zeroes.

to get the time as seconds:

 to_char( SYSDATE, 'SSSSS')

etc.

graham (aka grumpy)    

teetshd_at_ucbeh.san.uc.edu (greg teets) wrote...

| I am confused about the date format in Oracle. Can a record use a
| date column directly or do you have to use the TO_Date function?
|
| If it can be added directly, what is the format? All my date fields
| error out because of bad format.
|
| Thanks

Graham Miller ...
Opinions expressed are mine, they are free, and worth exactly what they cost. Received on Sun Jun 15 1997 - 00:00:00 CDT

Original text of this message

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