Hi, I'm trying to use the TalendDate addDate method. I need to be able to add 90 days to any given date to properly generate a date that many days from now. Is the addDate method the proper way to do this? If so, how do I go about using it. I can't seem to make sense of the Help section within the program and I haven't been able to find any useful instructions online. Thanks
Hi and welcome to the forum, Put your input file into a tMap component, on the output side of the tMap component. In the expression field on the ouput side of the tMap, use TalendDate.addDate(row1.MyDate, 90, "dd") You will have to replace row1.MyDate with the name of your date field. Good luck, Ben
Thanks for your quick reply. Do I need to include the date pattern? If so, how should it be shown? My input value is a string. Also, what will the output data type be? Can I keep it as a string? Thanks
I've tried doing this but when I run the test in the expression builder with a legitimate example value, I get "Exception in thread "main" java.lang.Error: Unresolved compilation problem:" TalendDate.addDate(row1.TransactionDate,"yyyyMMdd",90,"dd")
I've tried dropping what you suggested but I get an error message: "The method addDate(Date, int, String) in the type TalendDate is not applicable for the arguments (String, int, String)" My input is a string of format yyyyMMdd. I'd like my output to either be a date type or a string. And this is my code now as you suggested: TalendDate.addDate(row1.TransactionDate,90,"dd") The expression builder still throws a flag. Perhaps it would work if I actually did a run but I'm not ready with the rest of my job yet to do that. Thanks for your help. I just don't know what is going wrong.
Ok. row1.TransactionDate is currently formatted as a String. You will need to change that to a date. You can either do that at the point of import, or use nest the parseDate function inside the adddate. TalendDate.addDate(TalendDate.parseDate("yyyyMMdd", row1.TransactionDate),90,"dd")
I've tried getting it all set up and I gave my job a test run. Any ideas now? Exception in component tMap_1_TMAP_IN java.lang.RuntimeException: java.text.ParseException: Unparseable date: "" at routines.TalendDate.parseDate(TalendDate.java:643) at bonusme.transaction_processing_0_1.Transaction_Processing.tFileList_1Process(Transaction_Processing.java:3472) at bonusme.transaction_processing_0_1.Transaction_Processing.tMysqlConnection_1Process(Transaction_Processing.java:522) at bonusme.transaction_processing_0_1.Transaction_Processing.runJobInTOS(Transaction_Processing.java:7978) at bonusme.transaction_processing_0_1.Transaction_Processing.main(Transaction_Processing.java:7839) Caused by: java.text.ParseException: Unparseable date: "" at java.text.DateFormat.parse(DateFormat.java:337) at routines.TalendDate.parseDate(TalendDate.java:641) ... 4 more