BookmarkSubscribeRSS Feed
Choose Language Hide Translation Bar
Highlighted
fr2007
Community Trekker

calulating number of days using JSL

hi all

iam trying to calculate the difference between tow days using JSL..i have a script where I extract rows from an excel sheet that has the column value 0. After extracting the required rows, I want to calculate the differnce between tow dates and place the value in a new column. my script goes like this:

dt = data table("Final Sheet");

match_rows = dt << get rows where( :Column Type == 0 );

dt << subset(columns(), rows(match_rows));

Output Table("DateSheet");

can some one help me how I can add a column in the final output sheet and then calcuate the difference between the tow dates which are in columns E and C.

I thank all the JMP users for helping me out in JSL scripting..iam very new to JSL.

0 Kudos
1 ACCEPTED SOLUTION

Accepted Solutions
mpb
Super User mpb
Super User

Re: calulating number of days using JSL

In JMP, help>books>scripting guide. Either search for "new column" or navigate the second of the 2 indexes to N and from there to "new column". You will see some examples of creating a new column in JSL which contains a formula. Since JMP dates are in seconds from 1/1/1904, the difference between two dates is in seconds. Divide by 60 to get the number of minutes, 60*60 for the number of hours, or divide by 60*60*24 to get the number of days.

new column("Duration in Days", Formula((:E-:C)/(60*60*24)))

0 Kudos
1 REPLY 1
mpb
Super User mpb
Super User

Re: calulating number of days using JSL

In JMP, help>books>scripting guide. Either search for "new column" or navigate the second of the 2 indexes to N and from there to "new column". You will see some examples of creating a new column in JSL which contains a formula. Since JMP dates are in seconds from 1/1/1904, the difference between two dates is in seconds. Divide by 60 to get the number of minutes, 60*60 for the number of hours, or divide by 60*60*24 to get the number of days.

new column("Duration in Days", Formula((:E-:C)/(60*60*24)))

0 Kudos