Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
asafrian1700127126
Contributor II
Contributor II

Convert Datetime to Integer

Hi, i need to convert Datetime to Integer in Talend

- First i convert datetime to string 

TalendDate.formatDate("yyyy-MM-dd HH:mm:ss:SSSS",row4.TimeStamp)

- Second i convert string to integer

StringHandling.LEFT(Var.var1,4) ==> as var2 (for getting date in expression)

Integer.valueOf(Var.var3) ==> (in output table)

but get wrong like below

asafrian1700127126_0-1710824448201.png

There is no null data from the original table.

Then I added the following command and the data was successfully streamed but something went wrong in the YEAR column 
Var.var2!=null?Integer.parseInt(Var.var2):null

the result 

asafrian1700127126_1-1710824911166.png

The year column contains a NULL value and the data contents in the YEAR column are not aligned with the rows so they do not match the TimeStamp column.

Can you help to resolve this problem?

Labels (3)
1 Solution

Accepted Solutions
Shicong_Hong
Support
Support

Hi 

From the result of year column, there must exist null value in Var.var2. If Var.var1 is null, it generates a null value in Var.var2. For testing, print the value of Var.var1 on the console to see what data it is. 

Regards

Shicong

View solution in original post

1 Reply
Shicong_Hong
Support
Support

Hi 

From the result of year column, there must exist null value in Var.var2. If Var.var1 is null, it generates a null value in Var.var2. For testing, print the value of Var.var1 on the console to see what data it is. 

Regards

Shicong