Converting date to string and Integer to String in TMAP

One Star

Converting date to string and Integer to String in TMAP

Hi,
Could you some one advise on Converting date to string and Integer to String in TMAP.
This conversion should happen only in Tmap but not with tconvertype ...
Thanks,
Moderator

Re: Converting date to string and Integer to String in TMAP

Hi,
You can use method String.valueOf()in tMap to convert  Integer to String andTalendDate.formatDate("yyyy-MM-dd",myDate) to convert date to string.
Please take a look at my screenshots.
Best regards
Sabrina
--
Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.
Four Stars

Re: Converting date to string and Integer to String in TMAP

Hi

Please me on this below code. I have to change a date column to string type and the validate that whether it is valid date or not?

For validation it should come 0 or 1 a s output.

 

Employee

Re: Converting date to string and Integer to String in TMAP

@shivapanchal 

 

You have specified that you want to convert a date column to String and then validate whether its date. First of all, if the input column is having date data type, it will be always succeed in validation. So I assume your query is to check whether an input string is date or not. If has to give 1 as output if its a date value and 0 if its not a date value.

 

Please refer the below solution for this scenario.

image.png

 

image.png

 

The function is as shown below.

TalendDate.isDate(row1.data,"yyyy-MM-dd") ?"1":"0"

Warm Regards,
Nikhil Thampi

Please appreciate our Talend community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved

Four Stars

Re: Converting date to string and Integer to String in TMAP

Convert String to Date : 

TalendDate.parseDate("yyyy-MM-dd",Var.date_string )

 

Convert Int to Date : 

TalendDate.parseDate("yyyyMMdd", Integer.toString(Var.date_int) )

Dates_Talend.png

Thanks,
Developer @ minelead.io

2019 GARNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

What’s New for Talend Summer ’19

Watch the recorded webinar!

Watch Now

Put Massive Amounts of Data to Work

Learn how to make your data more available, reduce costs and cut your build time

Watch Now

How OTTO Utilizes Big Data to Deliver Personalized Experiences

Read about OTTO's experiences with Big Data and Personalized Experiences

Blog

Talend Integration with Databricks

Take a look at this video about Talend Integration with Databricks

Watch Now