Between/AND check and pass the value

Eight Stars

Between/AND check and pass the value

I need to check the column DATE is between 2017-01-01 and 2017-12-31. If YES, then i should pass the value as 1 to the output field. How can i do this?

 

When i gave <= and >= in tMAP, its not accepting.

Tags (1)

Accepted Solutions
Fifteen Stars TRF
Fifteen Stars

Re: Between/AND check and pass the value

Does this help you?

If so, thank's to mark your case as solved (Kudos also accepted).


TRF

All Replies
Fifteen Stars TRF
Fifteen Stars

Re: Between/AND check and pass the value

Try this:

TalendDate.compareDate(row1.yourDateField, TalendDate.parseDate("yyyy-MM-dd", "2017-01-01"), "yyyy-mm-dd") >= 0 &&
TalendDate.compareDate(row1.yourDateField, TalendDate.parseDate("yyyy-MM-dd", "2017-12-31"), "yyyy-mm-dd") <= 0

Hope this helps.


TRF
Eight Stars

Re: Between/AND check and pass the value

error. Input date field is string. Please suggest

 

Also, why its very complicated in talend just to compare two date. 

Fifteen Stars TRF
Fifteen Stars

Re: Between/AND check and pass the value

The example I gave you works fine for me.

Share your piece of code.

The date comparison is not "complicated" due to Talend but to Java.


TRF
Eight Stars

Re: Between/AND check and pass the value

OK..

 

I just changed the field name from your code given and ran.

tMap.jpg

 

 

error.jpg

Fifteen Stars TRF
Fifteen Stars

Re: Between/AND check and pass the value

EncounterActivityDate field seems to be a String but should be a Date.

Have a look to TalendDate.parseDate to convert from String to Date datatype.


TRF
Fifteen Stars TRF
Fifteen Stars

Re: Between/AND check and pass the value

Does this help you?

If so, thank's to mark your case as solved (Kudos also accepted).


TRF

What’s New for Talend Spring ’19

Watch the recorded webinar!

Watch Now

Definitive Guide to Data Quality

Create systems and workflow to manage clean data ingestion and data transformation.

Download

Tutorial

Introduction to Talend Open Studio for Data Integration.

Watch

Downloads and Trials

Test drive Talend's enterprise products.

Downloads