[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

How do I format the dates when creating table?

Posted on 2009-07-08
6
Medium Priority
?
243 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 17

Expert Comment

by:pssandhu
ID: 24804849
0
 
LVL 40

Accepted Solution

by:
mrjoltcola earned 2000 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 60

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 48

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

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

Question has a verified solution.

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

In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
One of the most important things in an application is the query performance. This article intends to give you good tips to improve the performance of your queries.
This video shows how to copy a database user from one database to another user DBMS_METADATA.  It also shows how to copy a user's permissions and discusses password hash differences between Oracle 10g and 11g.
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…

650 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