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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T11:36:22+00:00 2026-05-16T11:36:22+00:00

I need to convert a date from this format: 2002-10-10T12:00:00-05:00 (xs:dateTime as defined in

  • 0

I need to convert a date from this format:

2002-10-10T12:00:00-05:00
(xs:dateTime as defined in XML)

to an Oracle date.

I’m used to using this in PL/SQL: to_date(‘date here’, ‘yyyymmdd’), is there a way to convert this while keeping the time zone info?

Thanks

  • 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-16T11:36:22+00:00Added an answer on May 16, 2026 at 11:36 am

    Oracle dates don’t have timezone information. You’ll need to use a TIMESTAMP datatype instead.

    It works something like this:

    SQL> desc tz
     Name                                      Null?    Type
     ----------------------------------------- -------- ----------------------------
     ID                                                 NUMBER
     TS                                                 TIMESTAMP(6) WITH TIME ZONE
     TNOW                                               TIMESTAMP(6) WITH TIME ZONE
    
    SQL> insert into tz
      2  values (1
      3          , to_timestamp_tz('2002-10-10 12:00:00-05:00'
      4                           , 'YYYY-MM-DD HH24:MI:SSTZH:TZM')
      5          , systimestamp)
      6  /
    
    1 row created.
    
    SQL> select * from tz
      2  /
    
            ID
    ----------
    TS
    ---------------------------------------------------------------------------
    TNOW
    ---------------------------------------------------------------------------
             1
    10-OCT-02 12.00.00.000000 -05:00
    23-AUG-10 17.37.06.502000 +01:00
    
    
    SQL>
    

    Note, there is the tricky issue of the T in the XSD notation. That hurls a ORA-01858 exception, because it’s not a valid format in Oracle. I’m sure there is a workaround, but it currently escapes me.


    Well, one workaround is to apply SUBSTR() function sto split open the two parts of the timestamp, as Bob shows. But there ought to be a more elegant way.


    It probably doesn’t qualify as “elegant” but as it’s a string we can use a substitution function to get rid of the annoying T:

    SQL> insert into tz
      2  values (2
      3          , to_timestamp_tz(translate('2003-10-10T12:00:00-05:00', 'T', ' ')
      4                   , 'YYYY-MM-DD HH24:MI:SSTZH:TZM')
      5          , systimestamp)
      6  /
    
    1 row created.
    
    SQL> select * from tz
      2  /
    
            ID
    ----------
    TS
    ---------------------------------------------------------------------------
    TNOW
    ---------------------------------------------------------------------------
             1
    10-OCT-02 12.00.00.000000 -05:00
    23-AUG-10 17.37.06.502000 +01:00
    
             2
    10-OCT-03 12.00.00.000000 -05:00
    23-AUG-10 17.53.37.113000 +01:00
    
    
    SQL>
    

    But given all the effort Oracle have put into XMLDB it is rather annoying that there isn’t a tidier solution.


    “I dont understand how you get
    -05:00.”

    In my original sample I use a format mask of 'YYYY-MM-DD HH24:MI:SS-TZH:TZM'. This interprets the - in the time zone as a separator not a minus sign. Consequently it returned +05:00. I have since corrected my code sample to remove that last dash. Now the timezone is correctly rendered as -05:00. Sorry for any confusion.

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

Sidebar

Related Questions

I need to convert date from this format: 2011-11-04T18:30:49Z To this format: MM/dd/yy hh:mm:SS
I'm using XSLT 1.0 and need to convert a date format from dd/mm/yyyy to
I need to get a SQL query to output the date from a datetime
I need to convert my string date to datetime type. Here's one date scenario:
I need to convert a Joda-Time DateTime into a String, in the following format:
So I need to convert a date to a different format. With a bash
Is there a straightforward way of converting a Java SQL Date from format yyyy-MM-dd
I need to convert a date from a string (entered into a url) in
I'm working in postgresql and I need to convert the date format in query
Im importing content from an XML feed. The date format for the date field

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.