Discussions
Categories
- 385.5K All Categories
- 5.1K Data
- 2.5K Big Data Appliance
- 2.5K Data Science
- 453.4K Databases
- 223.2K General Database Discussions
- 3.8K Java and JavaScript in the Database
- 47 Multilingual Engine
- 606 MySQL Community Space
- 486 NoSQL Database
- 7.9K Oracle Database Express Edition (XE)
- 3.2K ORDS, SODA & JSON in the Database
- 584 SQLcl
- 4K SQL Developer Data Modeler
- 188K SQL & PL/SQL
- 21.5K SQL Developer
- 45 Data Integration
- 45 GoldenGate
- 298.4K Development
- 4 Application Development
- 20 Developer Projects
- 166 Programming Languages
- 295K Development Tools
- 150 DevOps
- 3.1K QA/Testing
- 646.7K Java
- 37 Java Learning Subscription
- 37.1K Database Connectivity
- 201 Java Community Process
- 108 Java 25
- 22.2K Java APIs
- 138.3K Java Development Tools
- 165.4K Java EE (Java Enterprise Edition)
- 22 Java Essentials
- 176 Java 8 Questions
- 86K Java Programming
- 82 Java Puzzle Ball
- 65.1K New To Java
- 1.7K Training / Learning / Certification
- 13.8K Java HotSpot Virtual Machine
- 94.3K Java SE
- 13.8K Java Security
- 208 Java User Groups
- 25 JavaScript - Nashorn
- Programs
- 666 LiveLabs
- 41 Workshops
- 10.3K Software
- 6.7K Berkeley DB Family
- 3.6K JHeadstart
- 6K Other Languages
- 2.3K Chinese
- 207 Deutsche Oracle Community
- 1.1K Español
- 1.9K Japanese
- 474 Portuguese
timezone conversion

Hi ,
Any idea how we can parse this format of timezone : 2018-04-16T16:55:52+0530
I tried multiple options but no luck. I am looking for timestamp format expression which can be used in SQLLDR. i tried 'YYYY-MM-DD"T"HH24MISS' and various combination but no luck...
Thanks
Answers
-
This should be fine :
my_field TIMESTAMP WITH TIME ZONE "YYYY-MM-DD\"T\"HH24:MI:SSTZHTZM"
If you're not sure about the format to apply, you can always look it up in the documentation :
-
If file column has different formats, is there any possibility to consume data by doing some kind of if else across multiple formats ? like
if format1 is not working then check with format2 and so on ?and if nothing works out then reject.
can anyone help me with sample for such cases ?
-
What's the data type of the target column?
Could you post some of the formats you expect?
-
Date of birth column datetype is TIMESTAMP(0)
we are getting below formats in file :
- TIMESTAMP WITH TIME ZONE "YYYY-MM-DD\"T\"HH24:MI:SSTZHTZM" ---- Major records have these format 95%
- 05/07/1981 ( MM/DD/YYYY ) ----around 3% is in this format
- 19790902000000 ( YYYYMMDDHH23MISS) ------ 1% in this format
- many other
In MYSQL - if format is adhere then it set value to NULL and proceed, there any flag at column level which we can use in this case ? ( as this is not much used column and we dont want to avoid record due to inconsistent data in this column )
-
In MYSQL - if format is adhere then it set value to NULL and proceed, there any flag at column level which we can use in this case ? ( as this is not much used column and we dont want to avoid record due to inconsistent data in this column )
Since Oracle 12.2 you can add a default value on conversion error clause to TO_TIMESTAMP_TZ:
-
Vicky007 wrote:Date of birth column datetype is TIMESTAMP(0)
Why not a DATE then?
Anyway, an option would be to create a dedicated conversion function to "try" the different formats.
Here's an example :
create or replace function to_timestamp_multi ( p_value in varchar2)return timestampdeterministicis fmtList sys.odcivarchar2list := sys.odcivarchar2list('YYYY-MM-DD"T"HH24:MI:SSTZHTZM','MM/DD/YYYY','YYYYMMDDHH24MISS');begin for i in 1 .. fmtList.count loop begin return to_timestamp_tz(p_value, fmtList(i)); exception when others then null; end; end loop; raise_application_error(-20000, utl_lms.format_message('Literal ''%s'' does not match any of the available formats', p_value));end;/
The list of formats could be extended, or parameterized, or cached (if you put the function in a package).
The function raises an exception if the input string matches none of the specified formats, but you could very well return a NULL instead.
There's still room for improvements, for instance regarding timezone handling (which, along with the time portion, is unusual for DOB data).
Usage in control file :
my_field char(30) "TO_TIMESTAMP_MULTI(:MY_FIELD)"