I have a table with that has time stamp for all the rows.
But I need only last 7 days data. Is there an easy way to delete all data that is past last 7 days.
New to jsl and any inputs will be helpful.
Here is a complete script that should show you a result
Names Default to Here( 1 ); dt = New Table( "test", add rows( 100 ), New Column( "start date", formula( Random Uniform( Today() - In Days( 12 ), Today() ) ), Format( "m/d/y", 10 ) ) ); dt:start date << delete formula; New Column( "START_SHORT_DATE", Formula( :start date - Time Of Day( :start date ) ), Format( "m/d/y", 10 ), ); New Column( "Todays Date", Formula( Today() - Time Of Day( Today() ) ), Format( "m/d/y", 10 ) ); New Column( "Ref Date", Formula( Today() - In Days( 7 ) ), Format( "m/d/y", 10 ), ); Current Data Table() << select where( :Ref Date < :START_SHORT_DATE );
dt << select where( today() - In Days( 7 ) < :Your date column ); dt << delete rows;
This will select all rows where your date column(replace its name in the first line of the JSL), is less than the current datetime - 7 days. Then the delete rows will delete all selected rows.
If you want the rows to be deleted to be 7 days prior to midnight, not 7 days before this point in time (today()), then you need to subtact the current time from the today() functions value.
dt << select where( today() - Time of Day( today() ) - In Days( 7 ) < :Your date column ); dt << delete rows;
This piece of script isnt working for me.
the " today() - Indays(7) part works but something wrong with Date comparision.
Debugger doesnt show any error but nothing happens when I run this. I am using JMP 12. Is that a problem?
I don't have JMP 12 available to me to verify if In Days() function is available. However, since all In Days() is doing is determining the number of seconds in a day, and then multiplying the result times the number in the (7), you can just change the formula to:
today()-7*60*60*24
Thanks for the response.As I mentioned above, I created a new column and printed today() - In Days(7) which works perfectly fine.
After this if I try comparing 2 columns,I dont see any result/error. All date columns are numeric.