Hi Experts,
I have a requirement to get the number of days between two dates using groovy script in cpi.
I am using the below script and it is giving me some error.
import com.sap.it.api.mapping.*; import java.util.GregorianCalendar; import java.util.Calendar; import java.util.Date; import java.text.SimpleDateFormat; import groovy.time.TimeCategory; def String customFunc(String startDate, String endDate){ def pattern = "yyyy-MM-dd"; def startDateF = new SimpleDateFormat(pattern).parse(startDate); def endDateF = new SimpleDateFormat(pattern).parse(endDate); use(groovy.time.TimeCategory) { def duration = (startDateF - endDateF).days; } return duration; }
Can you please help me correct the script to the find the number of days between two dates.