Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi All,
I need to convert a DATE to STRING with a condition.
I need to check if the incoming date (date with timestamp) is lesser than (current date + 7) days. If yes, then i need to pass a string like "To Be Expired" Else, I need to retain the incoming date (date with timestamp) value as it is. My incoming date column is of DateType DATE.
Can someone please help me to achieve this in tMap??
you should change below way.
Organiser.CRBExpiryDate== null ? Organiser.CRBExpiryDate : TalendDate.compareDate((TalendDate.addDate(TalendDate.getCurrentDate(),7,"dd")) ,Organiser.CRBExpiryDate)==1 ? "To Be Expired" :TalendDate.formatDate("dd/MM/yyyy", Organiser.CRBExpiryDate)
@joe86,you can compare this way in tmap.
TalendDate.compareDate(TalendDate.addDate(TalendDate.getCurrentDate() ,7,"dd") ,row2.date1)==1 ? "To Be Expired" :TalendDate.parseDate("dd/MM/yyyy", row2.date1)
@joe86,what date format are you getting form Mongo DB?
@joe86,still do you have issue?
also, do i need to change the data type of this date column to "string" after applying this formula??
@joe86,yes the output data type is sting. row2.date1 id date format.
TalendDate.compareDate(TalendDate.addDate(TalendDate.getCurrentDate() ,7,"dd") ,row2.date1)==1 ? "To Be Expired" :TalendDate.parseDate("dd/MM/yyyy", row2.date1)
@joe86,i am checking that the incoming date is lesser than the current+7 days ,since i was using "==1" in the expresion.