hi,
I would like to convert time in mn.
ex.: "01:30" in 90 mn; the new column must be in numeric+continuous to make graphs.
best regards
You can convert the character column directly into a numeric. I will use a slightly modified version of @gzmorgan0 data table for illustration. So given that table, with a new column added that is a character column with time values
Go to the Column Info for that column
The first thing is to change it to Data Type Numeric
Then you change the Modeling Type to Continuous
Change the format to a Duration format of hr:m
Then click on Apply to apply the changes
So now the column is a numeric column, with a duration format. And the format was used to read the original character strings which were in an hr:m format. But what you really want is to have the data displayed in minutes. So now that is a very simple change since the data are in numeric form. Just change the format to min:s
So now click on OK, and you data table is changed to the format you want
A better form might be:
{ hr, min } = Words( :Tps BaF, ":" ); 60 * Num( hr ) + Num( min );
See the attached table. Here is the formula. Note In Minutes() converts to seconds, so divide by 60*60
In Minutes( :Duration ) / (60 * 60)
thanks.
but my duration is in a caracter form....
Here is a formula that works.
Here is the corresponding code that youi can copy and then paste into your Formula Editor.
hr and min = Words( :Source, ":" ); 60 * Num( hr and min[1] ) + Num( hr and min[2] );
hi,I've written this in my sql post request:
column(dt,"Tps BaF")<<data type(Numeric)<<Modeling Type(Continuous)<<Format("h:m", 12);
then I can use nduration.Thanks for all.best regards
Hi,
I use the formula to use it with a script but I have this error message. I don't know what this error message means.
It appears that one of the entries for Tps Baf does not have a second values, so that when hr and min is created, there is only 1 subscript value.
I don't see where there are missing values:
{ hr, min } = Words( :Source, ":" ); 60 * Num( hr ) + Num( min );
For diagnosis, try this formula in a new column. The result should always be 2.
N Items( Words( :Tps BaF, ":" ) )