English 中文(简体)
通过Oracle显示时间格式
原标题:Display time format through Oracle

I wish to view my column time as hh24:mi:ss but even i insert it as to_date( 13:00:00 , hh24:mi:ss ). It still displays as date format. I have tried different methods to convert and i don t wish to alter the session.

我在此提出的表格:

CREATE TABLE Test
  (
    Name VARCHAR2(20),
    Description Varchar2(20),
    StudyTime Date,
    SleepTime Date,
  );

插入:

INSERT INTO Test 
VALUES( JUDY , STUDYING AT ABC , (To_Date( 01:00:00 ,  HH24:MI:SS )), 
            (TO_DATE( 06:35:00 ,  HH:MI:SS )));

显示结果:

Judy,Studying at abc,11-Nov-2011,11-Nov-2011

感谢任何人帮助!

最佳回答

Your IDE or SQL*Plus settings are displaying the default date format of DD-Mon-YYYY. Even though you are entering just a time format, oracle will still see it as a full date and time, hence the 11-Nov-2011 date (you need to be aware of this!).

When you then select all columns whichever interface you are using to display the results will show you the character representation of the date columns, if you have not specified what that is it will use the default NLS format settings. See: http://www.adp-gmbh.ch/ora/admin/nls_levels.html

要么修改国家最低生活水平标准格式,要么具体使用TO_CHAR

Try:

SELECT name,
       description,
       TO_CHAR(studytime,  HH24:MI:SS ) as studytime,
       TO_CHAR(sleeptime,  HH:MI:SS ) as sleeptime
  FROM test;

N.B. I used HH24 for study and H for sleeptime,与你在进入贵方价值观时所做的那样。

这种做法应该以正确的格式予以取消。

问题回答

暂无回答




相关问题
Mysql compaire two dates from datetime?

I was try to measure what is faster and what should be the best way to compare two dates, from datetime record in MySql db. There are several approaches how to grab a date from date time, but I was ...

iPhone Date Picker rolls over to 2010 on December 27th?

So I implemented a UIDatepicker in one of my applications for scheduling and autodialing teleconferences... everything is pretty much ready to go except, while testing I noticed that when the date ...

Convert date Python

I have MMDDYY dates, i.e. today is 111609 How do I convert this to 11/16/2009, in Python?

specifying date format when using $form->inputs() in CakePHP

I am wondering if there is a way to specify the date format in the forms created using CakePHP s $form->inputs(); Please note that this is not the individual $form->input() but instead $form->inputs() ...

NSDateFormat, super simple! Where am I screwing up?

Ok, this is really simple, maybe I m a getting a bit burnt out, but seems like it should work, Query XML feed, put out date string, format, display in a cell. The issue is I m a getting a NULL ...

sqlite writing a date into an email

I am exporting a date value from sqlite and placing it into an email. The date appears like this 279498721.322872 I am using Objective C in an Iphone App. Does anyone know how to make this export ...

热门标签