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

Announcements
Join us in Toronto Sept 9th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

parse int to date (tmap ) Talend postgresql

Hey all , My job Talend is about mapping between a csv file and a postregresql table. I need to insert a column date wich can be with normale format yyyyMMdd or(0/99999999) in the csv file.So if the date is equal to 0 or 99999999 it's will be mapping as a null variable in the database ,else the data must be loaded as a date type timestamp yyyy-mm-dd HH:mm:ss.

In the csv file i declared the date as an int , so i must parse int to a datetime in the tmap and loaded the 0/99999999 as a null variable . Any help please .

Labels (3)
1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

@sm 

 

Please refer the below flow for the solution.

0683p000009M562.png

 

0683p000009M5A3.png

 

0683p000009M5AD.png

 

Please note that while reading the csv, select String as the data type for input data (even if the data is integer). The function to be used is as below.

 

Relational.ISNULL(row1.input)|| row1.input.equalsIgnoreCase("99999999") || row1.input.equalsIgnoreCase("0")? null:TalendDate.parseDate("yyyymmdd",row1.input) 

Since your input value do not have time part, it will be automatically added as default values while checking from DB.

 

Hope I have answered your query. Please spare a second to mark the topic as resolved 🙂

 

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 🙂

 

View solution in original post

3 Replies
Anonymous
Not applicable
Author

you can use tMap and Var (for ex. Var.datetime)

(rowX.i == 0 || rowX.i == 99999999 ) ? null: TalendDate.parseDate("yyyyMMdd", Integer.toString(i))

rowX is a input row,
Var.datetime must be inserted to output row.

Anonymous
Not applicable
Author

@sm 

 

Please refer the below flow for the solution.

0683p000009M562.png

 

0683p000009M5A3.png

 

0683p000009M5AD.png

 

Please note that while reading the csv, select String as the data type for input data (even if the data is integer). The function to be used is as below.

 

Relational.ISNULL(row1.input)|| row1.input.equalsIgnoreCase("99999999") || row1.input.equalsIgnoreCase("0")? null:TalendDate.parseDate("yyyymmdd",row1.input) 

Since your input value do not have time part, it will be automatically added as default values while checking from DB.

 

Hope I have answered your query. Please spare a second to mark the topic as resolved 🙂

 

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
Author

Thank you 0683p000009MACn.png