Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8563753
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T17:02:09+00:00 2026-06-11T17:02:09+00:00

The following query succeeds: SELECT INTERVAL ’00:00:00.000000′ HOUR TO SECOND(6) FROM DUAL; The following

  • 0

The following query succeeds:

SELECT INTERVAL '00:00:00.000000' HOUR TO SECOND(6)
FROM DUAL;

The following fails:

SELECT INTERVAL time_field HOUR TO SECOND(6) -- time_field is a VARCHAR2(15)
FROM some_table;

w/ the following error:

ORA-00923: FROM keyword not found where expected

How do I fix my second query to pull back an HOUR TO SECOND INTERVAL?

When I try:

SELECT cast(time_field AS INTERVAL HOUR TO SECOND(6))
FROM some_table

I get the following:

ORA-00963: unsupported interval type

TEST SETUP:

CREATE TABLE some_table (
   time_field VARCHAR2(50)
);

INSERT ALL
INTO some_table (time_field) VALUES ('10:00:00.000000')
INTO some_table (time_field) VALUES ('12:00:00.000000')
INTO some_table (time_field) VALUES ('15:00:00.000000')
INTO some_table (time_field) VALUES ('17:00:00.000000')
INTO some_table (time_field) VALUES ('20:00:00.000000')
INTO some_table (time_field) VALUES (NULL)
SELECT * FROM DUAL;
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T17:02:10+00:00Added an answer on June 11, 2026 at 5:02 pm

    You can use the TO_DSINTERVAL function; example here using a CTE to replicate your table:

    WITH some_table AS (SELECT '00:00:00.000000' AS time_field FROM dual)
    SELECT TO_DSINTERVAL('0 ' || time_field)
    FROM some_table;
    
    TO_DSINTERVAL('0'||TIME_FIELD)
    ---------------------------------------------------------------------------
    +000000000 00:00:00.000000000
    

    Note that to make the format something the function recognises, you have to supply a ‘days’ part, hence the prepending of the dummy '0 ' string.

    Your fixed-value query returns a slightly different format (or at least displays slightly differently; interval daa types do not have format models in quite the same way as dates, so not sure how to express that accurately):

    SELECT INTERVAL '00:00:00.000000' HOUR TO SECOND(6)
    FROM DUAL;
    
    INTERVAL'00:00:00.000000'HOURTOSECOND(6)
    ---------------------------------------------------------------------------
    +00 00:00:00.000000
    

    To replicate that you can cast this if you need to:

    WITH some_table AS (SELECT '00:00:00.000000' AS time_field FROM dual)
    SELECT CAST(TO_DSINTERVAL('0 ' || time_field) AS INTERVAL DAY TO SECOND(6))
    FROM some_table;
    
    CAST(TO_DSINTERVAL('0'||TIME_FIELD)ASINTERVALDAYTOSECOND(6))
    ---------------------------------------------------------------------------
    +00 00:00:00.000000
    

    … or just:

    WITH some_table AS (SELECT '00:00:00.000000' AS time_field FROM dual)
    SELECT CAST('0 ' || time_field AS INTERVAL DAY TO SECOND(6))
    FROM some_table;
    
    CAST('0'||TIME_FIELDASINTERVALDAYTOSECOND(6))
    ---------------------------------------------------------------------------
    +00 00:00:00.000000
    

    … which is pretty much what @catcall first suggested, but this also needs the '0 ' prepended, or you get an ORA-01867. (Or, if you try to use HOUR TO SECOND, ORA-00963, even with the prepended day value). However, I guess (and it is just a guess, though very slightly educated) that it’s doing an implicit TO_DSINTERVAL or similar, and I think I’d prefer to use an explicit one so I was sure what’s happening. That might just be me, though…


    Using your sample data I too get an ORA-01867, but it’s caused by the null value. You can use a case to leave that as null in the result:

    SELECT CASE WHEN time_field IS NULL THEN null
        ELSE CAST('0 ' || time_field AS INTERVAL DAY TO SECOND(6)) END
    FROM some_table;
    
    CASEWHENTIME_FIELDISNULLTHENNULLELSECAST('0'||TIME_FIELDASINTERVALDAYTOSECO
    ---------------------------------------------------------------------------
    +00 10:00:00.000000
    +00 12:00:00.000000
    +00 15:00:00.000000
    +00 17:00:00.000000
    +00 20:00:00.000000
    
    
    6 rows selected.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The following query: select unnest(Table2.L) as X, unnest(Table1.O) from Table1, Table2 where Table1.code =
The following query: SELECT DISTINCT ClassName FROM SiteTree ORDER BY ClassName is returning things
The following query: WITH CteProductLookup(ProductId, oid) AS ( SELECT p.ProductID, p.oid FROM [dbo].[ME_CatalogProducts] p
The following query returns one row as expected when run from phpmyadmin. SELECT units
The following query: SELECT * FROM `objects` WHERE (date_field BETWEEN '2010-09-29 10:15:55' AND '2010-01-30
Following query does not work in access. SELECT Fields.FieldId, PrecisionSettings.DecimalPlaces from Fields left outer
The following query will not execute mysql_query(SELECT * FROM order WHERE orderID = 102;);
The following query is given in a PL/SQL procedure . SELECT e.data FROM extra
This following query returned null. SELECT `email`, `password`, `salt` FROM `users` WHERE `password` =
Following query runs well in MySQL 5.x SELECT m_area.id, m_area.cn_areaName, m_area.de_areaName, m_area.en_areaName,m_area.jp_areaName,t_shop.count FROM m_area

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.