Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
Khouloudy
Contributor
Contributor

How to upsert data files of previous month ?

Hello , 

I have a tfilelist component wich read positional files , i want to upsert(create or update) all files of previous month.

In the "RUN if" i wrote this condition :

TalendDate.compareDate(TalendDate.getFirstDayOfMonth(TalendDate.addDate(TalendDate.getCurrentDate(),-1,"MM")) , TalendDate.getFirstDayOfMonth(TalendDate.parseDate("yyyy-MM-dd", "mtime_string")), "yyyy-MM-dd")==0

and it will generate this error :

java.lang.NumberFormatException: For input string: "mtim"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
at java.lang.Integer.parseInt(Integer.java:580)
at java.lang.Integer.parseInt(Integer.java:615)
at routines.system.FastDateParser$DateParser.parse(FastDateParser.java:127)
at java.text.DateFormat.parse(DateFormat.java:364)
at routines.TalendDate.parseDate(TalendDate.java:928)
at routines.TalendDate.parseDate(TalendDate.java:886)
at local_project.importdonneesventeversionfinalmoisdernier_0_1.ImportDonneesVenteVersionFinalMoisDernier.tFileList_1Process(ImportDonneesVenteVersionFinalMoisDernier.java:1367)
at local_project.importdonneesventeversionfinalmoisdernier_0_1.ImportDonneesVenteVersionFinalMoisDernier.tSalesforceConnection_1Process(ImportDonneesVenteVersionFinalMoisDernier.java:911)
at local_project.importdonneesventeversionfinalmoisdernier_0_1.ImportDonneesVenteVersionFinalMoisDernier.runJobInTOS(ImportDonneesVenteVersionFinalMoisDernier.java:10709)
at local_project.importdonneesventeversionfinalmoisdernier_0_1.ImportDonneesVenteVersionFinalMoisDernier.main(ImportDonneesVenteVersionFinalMoisDernier.java:10471)
Exception in component tFileProperties_1 (ImportDonneesVenteVersionFinalMoisDernier)
java.lang.RuntimeException: java.text.ParseException: Unparseable date: "mtime_string"
at routines.TalendDate.parseDate(TalendDate.java:942)
at routines.TalendDate.parseDate(TalendDate.java:886)
at local_project.importdonneesventeversionfinalmoisdernier_0_1.ImportDonneesVenteVersionFinalMoisDernier.tFileList_1Process(ImportDonneesVenteVersionFinalMoisDernier.java:1367)
at local_project.importdonneesventeversionfinalmoisdernier_0_1.ImportDonneesVenteVersionFinalMoisDernier.tSalesforceConnection_1Process(ImportDonneesVenteVersionFinalMoisDernier.java:911)
at local_project.importdonneesventeversionfinalmoisdernier_0_1.ImportDonneesVenteVersionFinalMoisDernier.runJobInTOS(ImportDonneesVenteVersionFinalMoisDernier.java:10709)
at local_project.importdonneesventeversionfinalmoisdernier_0_1.ImportDonneesVenteVersionFinalMoisDernier.main(ImportDonneesVenteVersionFinalMoisDernier.java:10471)
Caused by: java.text.ParseException: Unparseable date: "mtime_string"
at java.text.DateFormat.parse(DateFormat.java:366)
at routines.TalendDate.parseDate(TalendDate.java:928)
... 5 more

Labels (3)
3 Replies
Anonymous
Not applicable

Hi
You don't use this function correctly.
TalendDate.parseDate("yyyy-MM-dd", "mtime_string"),
the second parameter should be a string date, eg:
TalendDate.parseDate("yyyy-MM-dd", "2020-02-18")

Regards
Shong
TRF
Champion II
Champion II

At least you need a data flow after tFileProperties to get the desired property.

Arrange your job like this:

0683p000009M9kZ.png

tFlowToIterate is used to get the mtime_string field value as a global variable:

0683p000009M9ke.png

Then for the If trigger, change the condition like this:

 

TalendDate.compareDate(TalendDate.getFirstDayOfMonth(TalendDate.addDate(TalendDate.getCurrentDate(),-1,"MM")) , TalendDate.getFirstDayOfMonth(TalendDate.parseDate("yyyy-MM-dd", (String)globalMap.get("mtime_string"))), "yyyy-MM-dd")==0

 

 

Khouloudy
Contributor
Contributor
Author

Thanks.I resolve the problem.