cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • Learn how to build custom Python data connectors and further customize JMP’s Data Connector Framework with the Python Data Connector Demo, available now in the JMP Marketplace!
  • See how to create experiments to support product design and ID useful product features. Register for June 12 webinar, 2pm US Eastern Time.

Discussions

Solve problems, and share tips and tricks with other JMP users.
Choose Language Hide Translation Bar
nicoleaba
Level I

Script to get last 6 months data

Hi,

 

What would be the best script to selected only the data of the exact last 6 months everytime the database is updated. 

1 REPLY 1
ian_jmp
Level X

Re: Script to get last 6 months data

It depends on what you mean by 'the database' and what workflow is best for the data you are handling, But, if you have data in a JMP table you can do this kind of thing:

 

NamesDefaultToHere(1);

// Make some 'date' data to play with
JMPstartDate = DateDMY(01,1,2013);
JMPendDate = Today();
dt = NewTable("DateTimes", 
		NewColumn("Date", Numeric, Continuous, 
			Formula(RandomInteger(JMPstartDate, JMPendDate)), 
			Format( "ddMonyyyy h:m:s", 22, 0 )
			),
		AddRows(1000)
		);
dt << runFormulas;
Column(dt, "Date") << deleteFormula;
dt << sort(By(:Date), replaceTable);

// Exclude and hide all rows older than six months ago:
// Look for 'DateIncrement()' in 'Help > scripting Guide'.
cutoff = Date Increment( Today(), "Month", -6, "actual" );
dt << selectWhere(:Date < cutoff);
dt << hideAndExclude;
dt << clearSelect;

 

Recommended Articles