Results 1 to 3 of 3
  1. #1
    Join Date
    Nov 2009
    Posts
    56

    Question Unanswered: convert date/time to YYYYMMDD format

    Hello Friends ,

    I am having field in Date/Time Format as 'MM/DD/YYYY HH24:MIS' and need to convert to YYYYMMDD which is a number data type .

    Can any one help in getting this conversion .

    Thanks/mIKE
    Last edited by MIKELALA; 12-21-14 at 19:59. Reason: Updated

  2. #2
    Join Date
    Aug 2003
    Location
    Where the Surf Meets the Turf @Del Mar, CA
    Posts
    7,776
    Provided Answers: 1
    Quote Originally Posted by MIKELALA View Post
    Hello Friends ,

    I am having field in Date/Time Format as 'MM/DD/YYYY HH24:MIS' and need to convert to YYYYMMDD which is a number data type .

    Can any one help in getting this conversion .

    Thanks/mIKE
    DATE datatype do NOT have any format. DATE datatype is stored in internal binary representation

    Code:
    SQL> desc emp
     Name                                      Null?    Type
     ----------------------------------------- -------- ----------------------------
     EMPNO                                     NOT NULL NUMBER(4)
     ENAME                                              VARCHAR2(10)
     JOB                                                VARCHAR2(9)
     MGR                                                NUMBER(4)
     HIREDATE                                           DATE
     SAL                                                NUMBER(7,2)
     COMM                                               NUMBER(7,2)
     DEPTNO                                             NUMBER(2)
    
    SQL> select hiredate, to_char(hiredate,'YYYYMMDD') FROM EMP WHERE ROWNUM = 1;
    
    HIREDATE  TO_CHAR(
    --------- --------
    17-DEC-80 19801217
    You can lead some folks to knowledge, but you can not make them think.
    The average person thinks he's above average!
    For most folks, they don't know, what they don't know.
    Good judgement comes from experience. Experience comes from bad judgement.

  3. #3
    Join Date
    Jun 2004
    Location
    Liverpool, NY USA
    Posts
    2,509
    and if you need it as a number

    to_number(to_char(hiredate,'YYYYMMDD'))
    Bill
    You do not need a parachute to skydive. You only need a parachute to skydive twice.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •