Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi All,
I am trying to calculate age of a product.
For this i need to subtract the current date from initial date (creation _date) and result should be in months.
Can someone help me with the logic for this ? As diffdate is not working with the string data types .
Please suggest
Hi, if your date are in String data type you can do something like this:
TalendDate.diffDate(TalendDate.parseDate("yyyy-MM-dd",(String of Date1)), TalendDate.parseDate("yyyy-MM-dd",(String of Date2)), "MM")
date pattern have to correspond to the date pattern of your String eg: "yyyy-MM-dd" for 2021-12-31
Send me love and kudos
I need to subtract it from the current date .
The current date - creation_date
so replace TalendDate.parseDate("yyyy-MM-dd",(String of Date1)) by TalendDate.getCurrentDate()
Hi,
I tried implementing it ,but I get the following error :
Type mismatch: cannot convert from long to String
Yes it's because diffDate return a Long and it seems you expect a String so :
String.valueOf(TalendDate.diffDate(TalendDate.getCurrentDate(), TalendDate.parseDate("yyyy-MM-dd",(String of Date2)), "MM"))