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

Announcements
Qlik and ServiceNow Partner to Bring Trusted Enterprise Context into AI-Powered Workflows. Learn More!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

get the day from a date with missing value

Hi,

I have a problem. I'd like to extract the day froma a date but it will have missing value --> " ". How can I extract the day from dates that have no null values? Thanks

Labels (2)
19 Replies
TRF
Champion II
Champion II

In the exception message, you should have the line number corresponding to the line where the exception occurs.
Go to the code tab in TOS, the go to the line number to know which instruction failed (and so, which field is null).
Anonymous
Not applicable
Author

I have this exception message: 

Exception in component tMap_1
java.lang.NullPointerException
at l10001_servicenow_timeworked.l10001_sn_0_1.L10001_SN.tFileInputXML_1Process(L10001_SN.java:8684)
at l10001_servicenow_timeworked.l10001_sn_0_1.L10001_SN.runJobInTOS(L10001_SN.java:9674)
at l10001_servicenow_timeworked.l10001_sn_0_1.L10001_SN.main(L10001_SN.java:9531)

 

I don't see the line number!

TRF
Champion II
Champion II

I would say line 8684 when processing 2nd of the XML file.
To be sure and to close the case, is it possible for you to send me an export of your job (right click on job name then export item) + the XML file?
Anonymous
Not applicable
Author

It's very big. Can you tell me in which way I can export the day from a day only if this record is Empty???

 

example:  date1 -> 2017-05-27 11:30:15   day -> 27 ....

                date2 ->      here nothing is stamp!

TRF
Champion II
Champion II

Here are the date values I use as an example:

0683p000009Lv4b.png

This give 2 record, 1 with a value, 1 which is null.

Here is the tMap to get the desired fields (yy, MM, dd and so on):

0683p000009Luyh.png

The syntax I used for each field is based on this one:

row80.fieldDate != null ? Integer.parseInt(TalendDate.formatDate("yyyy", row80.fieldDate)) : null 

When the input field is null, of fields on the output flow are null:

0683p000009LvAS.png

Anonymous
Not applicable
Author

HI, 

I send you an example of my XML file with a date null. 

 

1. I import all record as String except for integer and boolean;

0683p000009LvB1.png

 

2. Replace "." with "":

0683p000009Lunr.png

3. Convert String(closed_at and more datetype) in Date ("yyyy-MM-dd HH:mm:ss"):

0683p000009LuJ1.png

 

4. Use tMap for extract the day, month.... from two date (closed_at and sys_updated_on), but closed_at may have null value ("") (see point 2). In this poit Talend give me the error even if I use your function (row1.closed_at != null ? Integer.parseInt(TalendDate.formatDate("dd", row1.closed_at)) : null )     :

0683p000009LvBB.png

 

0683p000009Lv3j.png

 

this is all. Thanks again!

TRF
Champion II
Champion II

The field closed_at for the 2nd record is not null, it contains a ".".

So you replace the "." by an empty string "" which is not the same than a null value.

In tReplace, change "" by null and test again.

If you prefer not to change the tReplace, change in tMap for each field (don't forget the "!" at the beginning of the line):

!row80.fieldDate.equals("") ? Integer.parseInt(TalendDate.formatDate("yyyy",row80.fieldDate)) : null 

To be sure of which operation fails, click on the Code tab (on the bottom line of the designer workspace) and go to line 9037.

 

 

 

Anonymous
Not applicable
Author

Talend give me this error: 

 

Execution failed : Job compile errors
At least job "L10001_SN" has a compile errors, please fix and export again.
Error Line: 7395
Detail Message: The method closed_at(String) is undefined for the type L10001_SN.row1Struct
There may be some other errors caused by JVM compatibility. Make sure your JVM setup is similar to the studio.

 

 

and the code contains:

0683p000009Lv5s.png

Anonymous
Not applicable
Author

ok Thanks Thanks Thanks. It's all ok now!

TRF
Champion II
Champion II

Great!
It was a pleasure for me to try to understand your case and to help you.