Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
THRUST SERVICES & TOOLS
CLOUD EDITIONS
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
minutes into time (hour:minute)
birtprofi
Hello,
maybe one of you could use this script. If you have a time table with minutes, this script show the time in hour and minutes:
for example
100 minutes = 01:40
560 minutes = 09:20
and so on
best regards
Rafael
function hmin(minuten)
{
var minus = false;
if (minuten < 0)
{
minus = true;
minuten = minuten*(-1);
}
var ges = ""+(minuten/60);
var a = ges.split(".");
var h = ""+a[0];
var min_tmp = ""+(minuten%60);
var min_tmp1 = min_tmp.split(".");
var min = ""+min_tmp1[0];
if (minuten/60 < 1)
{
if (minus == true)
{
if (min == "")
return ges = "-00:00";
else if (min.length != 1)
return ges = "-00:"+min;
else
return ges = "-00:0"+min.length;
}
else
{
if (min == "")
return ges = "00:00";
else if (min.length != 1)
return ges = "00:"+min;
else if (min == "0")
return ges = "";
else
return ges = "00:0"+min;
}
}
if (minuten/60 >= 1)
{
if (minus == true)
{
if (min == "")
return ges = ((-1)*h)+":00";
else if (min.length == 1)
return ges = ((-1)*h)+ ":0"+min;
else return ges = ((-1)*h)+":"+min;
}
else
{
if (min == "")
return ges = h+":00";
else if (min.length == 1)
return ges = h+ ":0"+min;
else return ges = h+":"+min;
}
}
}
reportContext.setPersistentGlobalVariable("hmin", hmin);
Find more posts tagged with
Comments
bhanley
This would be a great script to include in an example report an upload it to the DevShare so people can actually see it in action.
Thanks for sharing.
tmseidel
...does not do
BirtDateTime.addMinute(new Date(0), minutes - 60)
the same?
Tom
bhanley
<blockquote class='ipsBlockquote' data-author="'tmseidel'" data-cid="67037" data-time="1280927998" data-date="04 August 2010 - 06:19 AM"><p>
...does not do <br />
<br />
BirtDateTime.addMinute(new Date(0), minutes - 60)<br />
<br />
the same?<br />
<br />
Tom<br /></p></blockquote>
<br />
I believe the script is simply converting one value (minutes) into an different quantifier (hours). The actual Date & time is not relevant. As such it is not a direct replacement for the BirtDateTime collection of functions because those require some fixed point in time to reference and display.
tmseidel
<blockquote class='ipsBlockquote' data-author="'bhanley'" data-cid="67038" data-time="1280928816" data-date="04 August 2010 - 06:33 AM"><p>
I believe the script is simply converting one value (minutes) into an different quantifier (hours). The actual Date & time is not relevant. As such it is not a direct replacement for the BirtDateTime collection of functions because those require some fixed point in time to reference and display.<br /></p></blockquote>
Tested and works...It returns a DateTime where the Date is not relevant. Advantage ist that this function works also with different locales.<br />
<br />
Tom
birtprofi
Hello Tom,
I don?t know how. Maybe you have an idea. (ok Brian gave the answer) Look at the example inferior.
the values in the column "SP5" are only minutes. It is not a date time column. With the function hmin I get the script startet.
best regards
rafael
tmseidel
<blockquote class='ipsBlockquote' data-author="'birtprofi'" data-cid="67040" data-time="1280929285" data-date="04 August 2010 - 06:41 AM"><p>
Hello Tom,<br />
<br />
I don?t know how. Maybe you have an idea. (ok Brian gave the answer) Look at the example inferior.<br />
<br />
the values in the column "SP5" are only minutes. It is not a date time column. With the function hmin I get the script startet.<br />
<br />
best regards<br />
rafael<br /></p></blockquote>
<br />
See the screenshot below:<br />
<br />
<img src='
http://farm5.static.flickr.com/4116/4859642713_a883f918ae_b.jpg'
alt='Posted Image' class='bbc_img' /><br />
<br />
the report parameter "minutes" is an integer-type<br />
<br />
Tom
Volker
Hello together,
I have a further problem. I tried both solutions and they work, but if the number of minutes is greater than 999 i don?t get a correct value.
Does anyone have an idea?
Volker
Volker
Hello again,
Can someone help me with the problem above?
Best regards
Volker