Subscribe Bookmark RSS Feed

Munger Columns with Variable Names

rfeick

Contributor

Joined:

Sep 30, 2016

I have a script that calculates progress data for a list of projects. One section creates a summary table to calculate the number of days each project spends in a given phase. The issue is that the :day:hr:m when I just want the number of days (For example: 17 rather than :17:00:00). Is there an easy way to do this? I've tried every possible way I can think of. I attached the relevent section of the script and the table that it generates.

1 ACCEPTED SOLUTION

Accepted Solutions
mpl34

Community Trekker

Joined:

Feb 16, 2016

Solution

You can cycle through the columns and replace the values, but there must be a better way. This converts the test table range columns:

namesdefaulttohere(1);
dt=currentdatatable();
for(i=1,i<=ncols(dt), i++,
	if(contains(columnname(i),"Range")>0,
		repmat=indays(column(dt,i)<<getasmatrix)/(24*60*60)^2;
		column(dt,i)<<setvalues(repmat)<<format("Best");
	)
);
3 REPLIES
rfeick

Contributor

Joined:

Sep 30, 2016

mpl34

Community Trekker

Joined:

Feb 16, 2016

Solution

You can cycle through the columns and replace the values, but there must be a better way. This converts the test table range columns:

namesdefaulttohere(1);
dt=currentdatatable();
for(i=1,i<=ncols(dt), i++,
	if(contains(columnname(i),"Range")>0,
		repmat=indays(column(dt,i)<<getasmatrix)/(24*60*60)^2;
		column(dt,i)<<setvalues(repmat)<<format("Best");
	)
);
rfeick

Contributor

Joined:

Sep 30, 2016

Why is the denominator (24*60*60)^2 and not just (24*60*60)?