TrackStudio Enterprise 3.2
Example 10

To calculate the number of months between the task submit date and the current date, use the following Task / Custom Field Value script. It can be used to find tasks submitted this month, last month, etc.

import java.util.Date;
Calendar ca = Calendar.getInstance();
ca.setTime(new Date(task.getSubmitdate().getTime().getTime()));
int submitMonth = ca.get(Calendar.MONTH);
int submitYear = ca.get(Calendar.YEAR);
ca.setTime(new Date());
int currentMonth = ca.get(Calendar.MONTH);
int currentYear = ca.get(Calendar.YEAR);
return (currentYear - submitYear)*12 + currentMonth - submitMonth;

Associated custom field properties:

Property 
Value 
Type 
Integer 
Copyright (c) 2002-2006. All rights reserved.