Solved

How do I format the dates when creating table?

Posted on 2009-07-08
6
233 Views
Last Modified: 2012-05-07
How do I properly format the dates in the following?
Date_Added & Date_Modified
Thanks!
Beth
CREATE TABLE CUSTOMER_SHIPPING_ADDRESS                           

  ( CUSTOMER_SHIP_ID (8,0) NOT NULL    

  , CUSTOMER_NO NUMBER(8,0) NOT NULL

  , CUSTOMER_SHIP_TYPE CHAR(1)

  , DATE_ADDED DATE(1)

  , DATE_MODIFIED DATE(30)

  , ADDRESS_1_SHIP VARCHAR2(50)

  , ADDRESS_2_SHIP VARCHAR2(50)

  , CITY_SHIP VARCHAR2(30)

  , STATE_SHIP VARCHAR2(20)

  , ZIPCODE_SHIP NUMBER(5,0)

  , COUNTRY_SHIP VARCHAR2(30)

  , CONSTRAINT CUSTOMER_SHIPPING_ADDRESS_PK PRIMARY KEY(CUSTOMER_SHIP_ID)           

  , CONSTRAINT CUST_SH_TYPE CHECK (CUSTOMER_SHIP_TYPE IN ('W', 'M', 'D', 'O'))

  , CONSTRAINT CUSTOMER_SHIPPING_ADDRESS_FK     FOREIGN KEY (CUSTOMER_NO)  

  , REFERENCES CUSTOMER(CUSTOMER_NO))                

                           

;

Open in new window

0
Comment
Question by:ba_trainer
6 Comments
 
LVL 17

Expert Comment

by:pssandhu
ID: 24804849
0
 
LVL 40

Accepted Solution

by:
mrjoltcola earned 500 total points
ID: 24804865
>>DATE_ADDED DATE(1)
>>, DATE_MODIFIED DATE(30)

THis is not the correct syntax. Just use DATE or TIMESTAMP

DATE_ADDED DATE
, DATE_MODIFIED DATE


dates are not stored in any special format, they are only formatted when you query them, using the default NLS_DATE_FORMAT as the default format, or using TO_CHAR() functions to explicitly format.

0
 
LVL 59

Expert Comment

by:Kevin Cross
ID: 24804883
Normally you don't format dates in the data structure.  It will store the date as the system needs it.  Now what matters is what format / language your system is setup to handle as that is how it will interpret literal dates if not specified.  You will want to format dates on output.

BTW, don't believe you need (1) or (30) with DATE data type.  Don't believe that even does anything, but maybe I am wrong as I am more of a MS SQL Server guy myself.
0
 
LVL 47

Expert Comment

by:schwertner
ID: 24805558
DATE type in Oracle has fixed internal format and length and format.
The designer uses the DATE or TIMESTAMP type to declare them.

Because the input of the DATE is in character string we use
TO_DATE conversion function like

TO_DATE('12-7-2008 14:15:55','mm-DD-yyyy hh24:MI:SS')
0
 
LVL 31

Expert Comment

by:awking00
ID: 24805786
See attached.
comments.txt
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Cursors in Oracle: A cursor is used to process individual rows returned by database system for a query. In oracle every SQL statement executed by the oracle server has a private area. This area contains information about the SQL statement and the…
'Between' is such a common word we rarely think about it but in SQL it has a very specific definition we should be aware of. While most database vendors will have their own unique phrases to describe it (see references at end) the concept in common …
This video explains at a high level with the mandatory Oracle Memory processes are as well as touching on some of the more common optional ones.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now