Talend parse date: unable to parse - date

I'm trying to insert data in my Database, my input is a string, representing a date in this format: yyyyMMdd ("20140525")
I try this in talend :
TalendDate.parseDate("yyyyMMdd",row1.date_pre_contrat)
but at runtime it does not work...
I've also tried
TalendDate.parseDate("yyyy-MM-dd",row1.date_pre_contrat)
but the result is the same.
Does someone have a any clue on what the problem is?

Solution found:
it was because i didn't tell Talend not to analyse the first line which contains the title.
Sorry for this

Related

Tableau: "Unknown function DATEPARSE called" after data source migration

Small question regarding Tableau and the DATEPARSE function please.
I used to have a CSV, nothing special, that has a column Mytimestamp.
The values of the column Mytimestamp would be just like those: Mytimestamp 1628670242328 1619671382146
DATE(DATEPARSE ( "yyyy-MM-dd HH:mm:ss", STR(DATEADD('second', (INT([Mytimestamp]/1000)), #1970-01-01#)) ))
Again, this worked really great, no problem.
Now, we have couple of other data sources, and I just replaced the original data source, the CSV file, to those new datasource.
Unfortunately, all dashboard using this broke, with this issue.
"Unknown function DATEPARSE called".
May I ask how to fix this, and get the behavior I was having with the CSV please?
What would be an alternative to this DATEPARSE function which can help "convert" those timestamps into a human readable format.
Thank you
The correct answer is to use DATETIME
DATE(DATEPARSE ( STR(DATEADD('second', (INT([Mytimestamp]/1000)), #1970-01-01#)) ))
Some data sources, such as CSV, supports DATEPARSE
But some others does not, and the DATETIME is the answer.

importing a text file in Access?

I have a large text file containing 4 attributes, I want to import this file in Microsoft access 2013 , but when the data is imported it gives an error
Type Conversion Failure
This error is occurring on Date Time field
The format of Date and Time is like that:
2008-02-02 15:36:08
Here is the sample of the file:
Sample of data
I guess you might have skipped explicitly defining the date format during the import procedure.
During the import process you need to click on advanced. This menu should appear:
you want to make sure that the highlighted fields match the date format in the text file.
EDIT: you will also want to make sure that the field is imported as Data Type Date Time

Date format in Talend "2006-05-27 17:00:00.000"

I am facing an issue with Talend dates. I have tried several solutions but still an "unparseable date" error persists.
My date format is of the form : "2006-05-27 17:00:00.000"
Can you help me ?
you can use below talendDate function to parse your string into date..
TalendDate.parseDate("yyyy-MM-dd HH:mm:ss.sss","2006-05-27 17:00:00.000")
this would take input as string and return you date.
If you don't handle the conversion yourself in a tMap but just want to use a schema, then: In your mapping configuration in the date field, you can add the following string:
yyyy-MM-dd HH:mm:ss.SSS
to set the correct format mapping for the date string. Otherwise the answer of garpitmzn is the way to go.
you should use this function in talend to fetch date:
TalendDate.parseDate("yyyy-MM-dd HH:mm:ss.SSS","2016-01-12 12:45:00.000")

Get a DateTime with an specific pattern with nscala-time

I am trying to get this pattern 'dd-MM-yyyy' with a variable of type DateTime
#{DateTimeFormat.forPattern("dd-MM-YYYY").parseDateTime(user.birthday.toString)}
But I am getting this error
java.lang.IllegalArgumentException: Invalid format: "2015-12-10T00:00:00.000Z" is malformed at "15-12-10T00:00:00.000Z"
Is there a way to do this with nscala-time?
makes a difference if I am using UTC?
UPDATE
For the moment I am casting to Date and doing this
#{Dates.format(user.birthday.toDate, "dd-MM-YYYY")}
But maybe is a better way without casting
thank you
So, if I understood your question correctly, you are trying to achieve the following:
Parse date from a string using a date format
Print/Display the date in another format.
Try the below:
#{Dates.format(DateTimeFormat.forPattern("yyyy-MM-dd'T'HH:mm:ss.SSSZ").parseDateTime(user.birthday.toString), "dd-MM-YYYY")}

Odd Logstash date parsing error

I'm getting the following error from Logstash:
{:timestamp=>"2013-12-30T17:05:01.968000-0800", :message=>"Failed parsing date from field", :field=>"message", :value=>"2013-12-30 17:04:59,539.539 INFO 14282:140418951137024 [foo.lib.base.onResults:152] -- /1.12/media - \"getMediaStoreUrl\": , 10.101.AA.BB, 10.101.19.254 took 0.170675992966, returning https://foo.s3.amazonaws.com/foo/customerMedia/1009238911/23883995/image?Signature=%2BfXqEdNWtWdhwzi%&*YEGJSDDdDFF%3D&Expires=1388455499&AWSAccessKeyId=NOIMNOTTHATSTUPID>, , >>>", :exception=>java.lang.IllegalArgumentException: Invalid format: "2013-12-30 17:04:59,539.539 INFO 14282:140418951137024..." is malformed at ".539 INFO 14282:140418951137024...", :level=>:warn}
The error is obviously about the date format, which comes to me as:
2013-12-30 17:04:59,539.539 INFO 14282:140418951137024...
And my pattern is as follows:
date {
match => ["message", "yyyy-MM-dd HH:mm:ss,SSS"]
}
I read up on the Joda-Time Library and I think I've got the format correct above. It's odd to me that the error message contains the doubled SSS (milliseconds) portion: ",539.539" (our logs output that way for some reason). I deliberately didn't put the second portion ".539" in my pattern because I want it ignored.
I am also successfully using the following pattern in another filter:
(?<pylonsdate>%{DATESTAMP}\.[0-9]+)
I'm just not exactly sure where this error is coming from. Any ideas what I need to do to correct this? Do I need to mutate #timestamp? Any help is appreciated!
The error is because the other information in "message" field will make date api parsing error.
Ex: INFO 14282:140418951137024...
You can use grok api to get the date and then use date api/
grok {
match => ["message","%{DATESTAMP:logtime}\.[0-9]+"]
}
date {
match => ["logtime","YY-MM-dd HH:mm:ss,SSS"]
}
I have tried this configuration with your log. It works on me. Hope this can help you .
FWIW, it may be due to this bug in the Logstash date filter.
I have a much simpler date filter that generates the same error, and came across your question while searching for the answer.