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 7544391
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T08:39:36+00:00 2026-05-30T08:39:36+00:00

When ececute the following SQL syntax in Oracle, always not success, please help. 40284.3878935185

  • 0

When ececute the following SQL syntax in Oracle, always not success, please help.

40284.3878935185 represents ‘2010-04-16 09:18:34’, with microsecond.

an epoch date of 01 January 1900 (like Excel).

create table temp1 (date1 number2(5,10));

insert into temp1(date1) values('40284.3878935185');

select to_date(date1, 'yyyy-mm-dd hh24:mi:ssxff') from temp1

Error report: SQL Error: ORA-01861: literal does not match format
string
01861. 00000 – “literal does not match format string”
*Cause: Literals in the input must be the same length as literals in
the format string (with the exception of leading whitespace). If the
“FX” modifier has been toggled on, the literal must match exactly,
with no extra whitespace.
*Action: Correct the format string to match the literal.

Thanks to Mark Bannister

Now the SQL syntax is:

select to_char(to_date('1899-12-30','yyyy-mm-dd') + 
date1,'yyyy-mm-dd hh24:mi:ss')  from temp1

but can’t fetch the date format like ‘yyyy-mm-dd hh24:mi:ss.ff’. Continue look for help.

  • 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-05-30T08:39:38+00:00Added an answer on May 30, 2026 at 8:39 am

    Simple date addition doesn’t work with timestamps, at least if you need to preserve the fractional seconds. When you do to_timestamp('1899-12-30','yyyy-mm-dd')+ date1 (in a comment on Mark’s answer) the TIMESTAMP is implicitly converted to a DATE before the addition, to the overall answer is a DATE, and so doesn’t have any fractional seconds; then you use to_char(..., '... .FF') it complains with ORA-01821.

    You need to convert the number of days held by your date1 column into an interval. Fortunately Oracle provides a function to do exactly that, NUMTODSINTERVAL:

    select to_timestamp('1899-12-30','YYYY-MM-DD')
        + numtodsinterval(date1, 'DAY') from temp3;
    
    16-APR-10 09.18.33.999998400
    

    You can then display that in your desired format, e.g. (using a CTE to provide your date1 value):

    with temp3 as ( select 40284.3878935185 as date1 from dual)
    select to_char(to_timestamp('1899-12-30','YYYY-MM-DD')
        + numtodsinterval(date1, 'DAY'), 'YYYY-MM-DD HH24:MI:SSXFF') from temp3;
    
    2010-04-16 09:18:33.999998400
    

    Or to restrict to thousandths of a second:

    with temp3 as ( select 40284.3878935185 as date1 from dual)
    select to_char(to_timestamp('1899-12-30','YYYY-MM-DD')+
        + numtodsinterval(date1, 'DAY'), 'YYYY-MM-DD HH24:MI:SS.FF3') from temp3;
    
    
    2010-04-16 09:18:33.999
    

    An epoch of 1899-12-30 sounds odd though, and doesn’t correspond to Excel as you stated. It seems more likely that your expected result is wrong and it should be 2010-04-18, so I’d check your assumptions. Andrew also makes some good points, and you should be storing your value in the table in a TIMESTAMP column. If you receive data like this though, you still need something along these lines to convert it for storage at some point.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The following PL/SQL will not execute and simply returns 'Invalid Argument' as an error.
I have the following PL/SQL being sent to a remote oracle 11gr2 server via
I get the following exception, java.sql.SQLSyntaxErrorException: Syntax error: Encountered 80 at line 1, column
Can someone please help me out with a query? In Microsoft SQL Server, I
I am using SQL Server 2008 management studio to execute the following SQL statements,
I'm trying to execute the following line: exit | sqlplus username/password@sid @test.sql Works great
In Oracle, I can use the following: String query = { ? = call
I'm attempting to execute an SSIS package on SQL 2005 using the following: dtexec
When writing parameterized queries in Classic ASP, I have been using the following syntax:
I have the following lines of code: sql = source C:\\My Dropbox\\workspace\\projects\\hosted_inv\\create_site_db.sql cursor.execute (sql)

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.