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
Forteen Stars TRF
Forteen 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
Forteen Stars TRF
Forteen 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. 

Forteen Stars TRF
Forteen 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

Forteen Stars TRF
Forteen 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
Forteen Stars TRF
Forteen 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