Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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
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
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?
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
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