sqloracle-databasehivedatastage

Datetime conversions through different systems


I'm currently working on a project where I need to import data from multiple sources and use them to build a reporting system.

One of the sources is a Hive table that has a timestamp column (VARCHAR) formatted like this:

'Jan 18 2019 1:54PM' 

My goal is, using SQL, to convert this column in something like this (24 hours format):

'YYYY-MM-DD HH:Mi:00'  

I'm bound to work with IBM Datastage in order to read from Hive and write to an Oracle database. The Oracle database is used to refresh a SQL Server tabular instance where I'll build my reports using PowerBI.

As I said, I'm bound to use specific software as per customer policy. I can use SQuirreL SQL to check the source tables, but so far I couldn't find a way to achieve my goal.

Any advice?


Solution

  • Turns out I needed to dive more into Hive functions.

    Here's the solution to my problem, using this SQL code I'm able to do the conversion while extracting the column:

    SELECT from_unixtime(unix_timestamp('Jan 18 2019 1:54PM', 'MMM dd yyyy h:mma'), 'yyyy-MM-dd HH:mm:00') AS formatted_date;
    

    Result:

    formatted_date
    2019-01-18 13:54:00