TMAP Less than Date comparison expression

Highlighted
Five Stars

TMAP Less than Date comparison expression

Hi,

 

I have a column from an input file row5.DATE_OF_BIRTH with the date pattern set as: "dd-MM-yyyy"

The output column has also the same date pattern set.

 

I am trying to compare the date from row5.DATE_OF_BIRTH to 01-01-1900.

If it is less than "01-01-1990" or null, I want to null the output value, else I want to use the date in row5.DATE_OF_BIRTH.

 

Please could you help.

 

Thanks

K

 


Accepted Solutions
Fifteen Stars TRF
Fifteen Stars

Re: TMAP Less than Date comparison expression

Try this one:

row5.DATE_OF_BIRTH == null || 
TalendDate.compareDate(row5.DATE_OF_BIRTH, 
       TalendDate.parseDate("dd-MM-yyyy", "01-01-1990", "dd-MM-yyyy")) < 0 ? null : row5.DATE_OF_BIRTH 

TRF

All Replies
Fifteen Stars TRF
Fifteen Stars

Re: TMAP Less than Date comparison expression

Hi,

Should work with something like that:

row5.DATE_OF_BIRTH == null || 
TalendDate.compareDate(row5.DATE_OF_BIRTH, 
TalendDate.parseDate("dd-MM-yyyy", "01-01-2010", "dd-MM-yyyy)) < 0) ? null : row5.DATE_OF_BIRTH

Hope this helps.


TRF
Five Stars

Re: TMAP Less than Date comparison expression

Thanks for the response,

 

this doesn't seem to work.

 

I also added double quotes to dd-MM-yyyy.

I get an error (object is not an instance of declaring class)

Fifteen Stars TRF
Fifteen Stars

Re: TMAP Less than Date comparison expression

You're right, the correct syntax is:

 

row5.DATE_OF_BIRTH == null || 
TalendDate.compareDate(row5.DATE_OF_BIRTH, 
       TalendDate.parseDate("dd-MM-yyyy", "01-01-1990", "dd-MM-yyyy")) < 0) ? null : row5.DATE_OF_BIRTH 

Can you share your tMap with the schemas?


TRF
Five Stars

Re: TMAP Less than Date comparison expression

please see attached.

 

Fifteen Stars TRF
Fifteen Stars

Re: TMAP Less than Date comparison expression

Try this one:

row5.DATE_OF_BIRTH == null || 
TalendDate.compareDate(row5.DATE_OF_BIRTH, 
       TalendDate.parseDate("dd-MM-yyyy", "01-01-1990", "dd-MM-yyyy")) < 0 ? null : row5.DATE_OF_BIRTH 

TRF
Five Stars

Re: TMAP Less than Date comparison expression

This worked .

 

I had to remove the final   "dd-MM-yyyy" from TalendDate.parseDate("dd-MM-yyyy", "01-01-1990", "dd-MM-yyyy")) to make it work.

 

Thank you

 

Would you happen to know how i can limit the output of a row to 50chars even though the input may be 300charrs?

15TH OCTOBER, COUNTY HALL, LONDON

Join us at the Community Lounge.

Register Now

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

Best Practices for Using Context Variables with Talend – Part 4

Pick up some tips and tricks with Context Variables

Blog

How Media Organizations Achieved Success with Data Integration

Learn how media organizations have achieved success with Data Integration

Read

Why Companies Move to the Cloud: 7 Success Stories

Learn how and why companies are moving to the Cloud

Read Now