JSL: Difference from TodayHi all,
I'm trying to use JMP to calculate the number of days between the return of a product and today using a for loop. For some reason, however, it only returns blank cells when I try and run it. Could someone take a look at my code, as I can't understand why this isn't working.
For( i = 1, i <= N Rows(df), i++,
col[i] = Date difference (
Today(),
:Name("Product Returned Date")[i],
"Day"
)
);
Thanks
Re: JSL: Difference from TodayThanks, I knew it would be something simple.
Re: JSL: Difference from TodayHere is a simple script using your code(without change) that seems to work. You may not be referencing your column "col" properly...check that out
Names Default To Here( 1 );
df = Open( "$SAMPLE_DATA\Time Series\Monthly Sales.jmp" );
df:date << set name( "Product Returned Date" );
df << New Column( "Difference" );
col = column("Difference");
For( i = 1, i <= N Rows( df ), i++,
col[i] = Date Difference( Today(),
:Name( "Product Returned Date" )[i],
"Day" )
);Re: JSL: Difference from Today@jdcoughtrey,
What is the format of "Product Returned Date" ? Can you post a sample of your data ? I would suggest ensuring that the format of the column is also numeric and it is a valid date. I would even put a Try() and Throw() block to throw an error or missing value if te Product Returned Date could have invalid or non-numeric values.