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??
@joe86,then use the below way.
TalendDate.compareDate(TalendDate.addDate(TalendDate.getCurrentDate() ,7,"dd") ,row2.date1)==-1 ? "To Be Expired" :TalendDate.parseDate("dd/MM/yyyy", row2.date1)
@joe86, use the below one
TalendDate.compareDate(TalendDate.addDate(TalendDate.getCurrentDate() ,7,"dd") ,row2.date1)==-1 ? "To Be Expired" :TalendDate.formatDate("dd/MM/yyyy", row2.date1)
hello,
still facing the same error. see below the screenshot on how i have given in tMap.
I have changed the data type to string also.
@joe86,in the expression else part use the TalendDate.formatDate("dd/MM/yyyy", row2.date1)
@joe86, handle below way for nulls.
row2.date1==null ?row2.date1 : TalendDate.compareDate(TalendDate.addDate(TalendDate.getCurrentDate() ,7,"dd") ,row2.date1)==-1 ? "To Be Expired" :TalendDate.formatDate("dd/MM/yyyy", row2.date1)
@joe86,please accept the solution and provide Kudos also
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)