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

Announcements
See why IDC MarketScape names Qlik a 2025 Leader! Read more
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Convert from date to int

Is there any way to implement this SQL method to convert date to int in Talend Open Studio?

convert(int, convert(varchar(10), mydate, 112)) 

Labels (4)
1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Date d = sdf.parse("2018-12-19");
sdf.applyPattern("yyyyMMdd");
String newDateString = sdf.format(d);   //20181219

Use SimpleDateFormat parse/format depending on input/output data type (i.e. String or Date)

View solution in original post

6 Replies
Anonymous
Not applicable
Author

Can you give an example of input(s) and expected output(s)

Anonymous
Not applicable
Author

Input : 2018-12-19

Expected output : 20181219

Anonymous
Not applicable
Author

SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Date d = sdf.parse("2018-12-19");
sdf.applyPattern("yyyyMMdd");
String newDateString = sdf.format(d);   //20181219

Use SimpleDateFormat parse/format depending on input/output data type (i.e. String or Date)

Anonymous
Not applicable
Author

where should i write this code

can i convert the ouput to "int" type?

Anonymous
Not applicable
Author

Depends on the requirements, if you're parsing row by row, pass the  input to a tJavaRow and put that code in making sure to pass the row value in and then out. 

You can use Integer.parseInt() to convert string to int.

Anonymous
Not applicable
Author

Thank you soo much 0683p000009MACn.png