Solved

How do I format the dates when creating table?

Posted on 2009-07-08
6
235 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 32

Expert Comment

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

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Background In several of the companies I have worked for, I noticed that corporate reporting is off loaded from the production database and done mainly on a clone database which needs to be kept up to date daily by various means, be it a logical…
Composite queries are used to retrieve the results from joining multiple queries after applying any filters. UNION, INTERSECT, MINUS, and UNION ALL are some of the operators used to get certain desired results.​
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
This video shows how to recover a database from a user managed backup

776 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