Unparseable date error in Pentaho - mysql

I am using Pentaho to insert and update a table in Mysql.
Source database being oracle 11g and destination is Mysql database.
The query for getting max syncronization time from oracle is
SELECT
max(SYNC_TIME) AS LST
FROM Abc_ADM.ORA_SYNC_STATS
where SYNC_TIME is of Timestamp(6) datatype in Oracle in format 01-FEB-70 12.00.00.000000000 AM.
when i use this query and run the job i get error-
could not convert string [${LST}] to date using format [yyyy/MM/dd HH:MM:ss:SS] on offset location 0
unparseable date [${LST}]
What is that i am declaring wrong? please help

Pentaho is asking for a date-format like
yyyy/MM/dd HH:MM:ss:SS
But your Oracle-Output is different:
01-FEB-70 12.00.00.000000000 AM
For Pentaho its a string, no date at all.
It should work by telling Pentaho the Date-Format:
dd-MMM-yy HH.mm.ss
Do this in an input-Step
or by using a select-values ("Meta-data") step after your input
Important:
Type should be "Date" and Format: dd-MMM-yy HH.mm.ss
I can't post screenshots where you could have seen that it works for me.
T [1]: http://i.stack.imgur.com/1AuPW.jpg

Related

SQL Query nvarchar to date

I am working on SAP HANA Studio and have tried to run SQL command that converts an entire column of field, nvarchar, into one of field, date.
My dates have format: dd-mon-yyyy (i.e '29-Mar-1997') with field nvarchar(11).
I have looked at previous questions and SQL command documentation (for functions like CAST, CONVERT, TO_DATE, STR_TO_DATE) and have not gotten a solution.
Typical errors I get are: Function not recognized, or, Error while parsing Service Date as DATE at function to_date().
Any suggestions?
Thanks
-Diana
Try TO_DATE():
select to_date(col, 'DD-MON-YYYY')
Obviously your database driver/layer in SAP HANA does not support all mySQL functions.
Please connect to your database directly (using command-line or a gui like HeidiSQL) and create a view in your database:
CREATE VIEW view_tablename AS
SELECT STR_TO_DATE(`Service Date`, '%d-%b-%Y') AS ServiceDateDt, * FROM tablename
Then use view_tablename instead of tablename in all your queries - because view_tablename has the additional date field "ServiceDateDt".

converting java time to sqldate in query

java datetime (date.getTime()) is stored as string in mysql field.
How can we convert this to sql date using sql query. I am using mysql database.
Is there any sql function available?
For example - This is stored (1416231812348) for today's date in db.
Thanks for suggestions.
Java is returning the date as a long, to convert it you can use:
SELECT FROM_UNIXTIME(event_time) FROM MY_TABLE
If you get an error, try the following (after testing, I can see that your data is stored in milliseconds so you need to use this method):
SELECT FROM_UNIXTIME(event_time/1000) FROM MY_TABLE
(Change event_time to be the field name in your table and MY_TABLE to be the table name.)
Here is a SQLFiddle example that shows it working.
Here is an answer that gives you formatting options as well:
http://notsoyellowstickies.blogspot.co.uk/2011/11/converting-long-into-datetime-mysql.html
There is a java.sql package, that has time included. You can send it straight into your database without needing to convert it.
This may be a more pre-emptive solution than converting a date string from Java, into time in MySQL.
A similar question was answered and may be able to help you out here:
A datetime equivalent in java.sql ? (is there a java.sql.datetime ?)
most probably you have recorded from:
System.currentTimeMillis()
so:
select DATE_FORMAT ( from_unixtime( your_table_field / 1000 ) , '%e %b %Y');
you can change the date format as you like.

SSIS datatype mismatch

I am trying to import from an oracle Source,I have a date field both on the source and destination.Its throwing error "there was an error with the input column on input OLE DB Destination failed with error code oxco209029A occured while processing input "OLE DB destination input(3554)".
I am trying to cahnge it to char in the Oracle query and change it to back to date..in the SSIS using data conversion, and it didnt work as well,may be I am doing something wrong,Could you guys have alook at this?I really appreciate it..Thanks guys
Here are three of my previous answers on this topic.
https://stackoverflow.com/a/11585853/236348
https://stackoverflow.com/a/2231164/236348
https://stackoverflow.com/a/11229159/236348
Oracle and SQL Server date types are a known incompatibility.
Oracle to SQL server Date conversion
Oracle to SQL Server: Date Conversion & Format
http://sql-troubles.blogspot.com/2010/02/oracle-vs-sql-server-date-conversion.html
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=98943
etc.
You've cast the Oracle type to some string equivalent and SQL Server isn't accepting the input for a (date, datetime, datetime2?) data type. Generally your options are to clean up your cast to be a recognizable date format or add a Derived Column Transformation to change the input string column to the SSIS equivalent. The exact type depends on what your target table has defined.

SSIS (2008R2) import from mssql to mysql failing due to a date column

I have an oledb connection to mssql and an ado.net destination (with odbc driver used) to mysql. The tables are exectly the same and all the columns are working bar one.
The error message received is:
[ADO NET Destination [325]] Error: An exception has occurred during data insertion, the message returned from the provider is: Unable to cast object of type 'System.DateTime' to type 'System.Char[]'.
I've seen similar questions on other data types but the resolution of changing to string does not work here. If I convert to string (has to be length 29 otherwise the conversion step fails) I get the following error message:
[ADO NET Destination [325]] Error: An exception has occurred during data insertion, the message returned from the provider is: ERROR [HY000] [MySQL][ODBC 5.1 Driver][mysqld-5.5.15]Incorrect datetime value: '2011-03-21 11:23:48.573000000' for column 'LastModificationDate' at row 1
Other potentially relevant details:
connection driver- {MySQL ODBC 5.1 Driver}
script run before dataflow - set sql_mode='STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION,ANSI_QUOTES'
Other datetime columns are working
This column has a reasonably high proportion of nulls
mssql spec: [LastModificationDate] [datetime] NULL
mysql spec: LastModificationDate datetime NULL
Has anyone had experience with this issue and could provide some advice on resolving it?
Can you try converting it to string on sql server side in your query using:
convert(char(10),LastModificationDate,111)+' '+convert(char(8),LastModificationDate,108)
This works for me all the time.
I got the same big headache this week. I tried many ways. Thanks God, finnally, one of them worked. Hope it could help you a little bit.
For some columns with the data type of Int, datetime, decimal....,here, I identified as ColumnA, and I used it as datetime type.
1.in Data Flow Source, use SQL Command to retrieve data. Sth like select isnull(ColumnA,'1800-01-01') as ColumnA, C1, C2, ... Cn from Table
Make sure to use Isnull function for all columns with the datatype mentioned before.
2.Excute the SSIS pkg. It should work.
3.Go back to Control Flow, under the data flow task, add SQL Task control to replace the data back. I mean, update the ColumnA from '1800-01-01' to null again.
That works for me. In my situation, I cannot use ignore failure option. Because if I do, I will lose thousands rows of data.

Entity Framework - MySQL - Datetime format issue

I have a simple table with few date fields.
Whenever I run following query:
var docs = ( from d in base.EntityDataContext.document_reviews
select d ).ToList();
I get following exception:
Unable to convert MySQL date/time value to System.DateTime.
MySql.Data.Types.MySqlConversionException: Unable to convert MySQL date/time value to System.DateTime
The document reviews table has two date/time fields. One of them is nullable.
I have tried placing following in connection string:
Allow Zero Datetime=true;
But I am still getting exception.
Anyone with a solution?
#effkay - if you solved this it would be great if you could post the answer.
Also if anyone else has a solution that would be great too :).
Edit:
The solution can be found in the http://dev.mysql.com/doc/refman/5.1/en/connector-net-connection-options.html connector documentation.
I needed to set "Convert Zero Datetime" to true, and now it works.
hth.
You need to set Convert Zero Datetime=True in connection string of running application