Solved

How do I format the dates when creating table?

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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

How to Create User-Defined Aggregates in Oracle Before we begin creating these things, what are user-defined aggregates?  They are a feature introduced in Oracle 9i that allows a developer to create his or her own functions like "SUM", "AVG", and…
Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
Via a live example show how to connect to RMAN, make basic configuration settings changes and then take a backup of a demo database
This video shows syntax for various backup options while discussing how the different basic backup types work.  It explains how to take full backups, incremental level 0 backups, incremental level 1 backups in both differential and cumulative mode a…

932 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

11 Experts available now in Live!

Get 1:1 Help Now