Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
stvn
Contributor
Contributor

convert a Date in string format to a date in a Date format with another ouput format

Hi all,

Can any one help me to solve this issue? I have as an output an excel file with a date with this format: 01.05.2015 (dd/MM/yyyy) I'd like to have as an output, a date in a Date type with this format: yyyy-MM-dd'T'HH:mm:ss.SSS'Z'. 

This is what I typed in my tMap: (row10.CREATED!=null)?TalendDate.parseDate("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'",row10.CREATED):null  and unfortunately it gave me as an ouput: Thu Apr 14 00:00:00 CEST 2016

I tried to use a TalendDate.formatDate but it didn't work. 

I'd appreciate any help, thanks in advance

Regards,

 

Stvn

Labels (2)
15 Replies
stvn
Contributor
Contributor
Author

Hi again,

I convert the file into csv files and all dates are formated 14.04.2016. I Strutured my Job as shown below: 


0683p000009M3By.png

 

When I run the Job without the second tMap I can see my dates results. When I add the second tMap where I tried to convert in a dateFormat, It gives me an error. You can see bellow the result from my last running. Dates are formatted in this way:

|31.07.2006
|31.07.2006
|31.07.2006
|31.07.2006

Is there any way to format all dates in a tJavaRow?

Warm Regards,

thank you for your time

Steve

 

stvn
Contributor
Contributor
Author

Hi, 

You will find as an attachment a copy of my excel sheet in xlsx to test


StringDateToConvert.xlsx
stvn
Contributor
Contributor
Author

Hi,

@nthampi 

@manodwhb 

You will find as an attachment a copy of my excel sheet to test. Thank you in advance


StringDateToConvert.xlsx
Anonymous
Not applicable

H Steve,

 

     Thanks for the sample file and it really helped to identify the issue. I have used them to transform the data and I was able to print them successfully. The most important change was to read the input data in Date format itself so that we will not face the change in format issue later.

 

    Please refer the screen shots below.

0683p000009M3Dk.png

 

Now, the input schema for excel is as shown below.

0683p000009M2yI.png

tMap screenshot as shown below.

0683p000009M3Dp.png

 

the tMap functions are as shown below.

 

Relational.ISNULL(row1.DATE)?null:
TalendDate.parseDate("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'",TalendDate.formatDate("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'",row1.DATE)) 

Relational.ISNULL(row1.DATE_2)?null:
TalendDate.parseDate("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'",TalendDate.formatDate("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'",row1.DATE_2)) 

Warm Regards,
Nikhil Thampi

Please appreciate our Talend community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂

Anonymous
Not applicable

@stvn 

 

Could you please mark the topic as resolved so that it will help other community members also during reference?

 

Warm Regards,
Nikhil Thampi

Please appreciate our Talend community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂

stvn
Contributor
Contributor
Author

Hi,
@nthampi
Your provided solution works pretty well. Again great thanks for your support and your help.
Have a great day.
Warm Regards,
Stevn