Continue to Site

Welcome to MCAD Central

Join our MCAD Central community forums, the largest resource for MCAD (Mechanical Computer-Aided Design) professionals, including files, forums, jobs, articles, calendar, and more.

Search date range in script

JamesM

New member
I'm trying to modify an Intralink 3.4 script to allow me to search for files created over a time period. I would like it set so that, whenever it runs, it will look at the previous seven days. The script as Intralink created it gave me the lines:


IL.addFilter( "Created On", "<=", new Object[]{new java.util.Date(1203351660000L) } ); // recorded step: 9
IL.addFilter( "Created On", ">", new Object[]{new java.util.Date(1202746860000L) } ); // recorded step: 10


I changed the first line to:


IL.addFilter( "Created On", "<=", new Object[]{new java.util.Date() } ); // recorded step: 9


and it now selects from the time that the script runs, but I cannot figure out how to set the second line to always be seven days (or 604800000 milliseconds) less than the first. Is there a Java function or something else to accomplish this?
 
Here is what I used to get the previous month for Intralink 3.3. You will have to create the code to obtain 7 days previous. There may be a simpler way to do this that I do not know.


************************************************************ **************************
// Version: Intralink v.3.3, ()
// Start Macro Recording
import com.ptc.intralink.client.script.*;
import com.ptc.intralink.script.*;



import java.text.*;


public class date extends ILIntralinkScript {
ILIntralinkScriptInterface IL = (ILIntralinkScriptInterface)getScriptInterface();


private void run0 () throws Exception {



SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy HH:mm");
String mydate = sdf.format(new java.util.Date());
int dateindex1 = mydate.indexOf('/');
int dateindex2 = mydate.lastIndexOf('/');
String mymonth = mydate.substring(dateindex1+1, dateindex2);
String myyear = mydate.substring(dateindex2+1, dateindex2 +5);
int mth = Integer.parseInt(mymonth);
int year = Integer.parseInt(myyear);


mth = mth - 1;
if (mth == 0) {
mth = 12;
year = year - 1;
}


String newmth = Integer.toString(mth);
String newyear = Integer.toString(year);
String checkdate = mydate.substring(0, dateindex1+1) + newmth + ("/") + newyear +


mydate.substring(dateindex2+5, mydate.length());


IL.addFilter( "Created On", ">=", new Object[]{checkdate} );


} // End of run0
public void run () throws Exception {
run0 (); // recorded
} // End of function


} // End Macro Recording


************************************************************ ************************


Hope this helps
 
Hello,

I have very little knowledge about Intralink and no Java knowledge, but was wondering if it's possible when checking in a part in Intralink 3.4 to have it check if a parameter 'drawn_date' in a part is consistent with the currrent date. We have this parameter defined as a string value and set it to 'dd-mm-yyyy'.

Ideally I want to be warned when trying to check-in a part with the wrong date in the parameter...

Is this possible?
 
Yes, what you describe sounds possible. I have used date comparison in scripts - I have not done it with a dateas astring value but Java has a function for that conversion.


Marc Mettes and Dwaraka Nadha Reddy Manchuri have written some excellent tutorials on scripting. If you're interested in learning more, check out the caddigest website.
 

Sponsor

Articles From 3DCAD World

Back
Top