Hours/Days

Forum for users that want to write their own custom queries against the PT database either via the Structured Query Language (SQL) or using the PT3 custom stats/reports interface.

Moderator: Moderators

Re: Hours/Days

Postby FilS2BotS » Tue Sep 28, 2010 9:40 am

((cnt_minutes / cnt_days_played) / 60) work and the thing is it give me results like 2.196996 (number of hours) and i would like a format like 2:14 (its hours and minutes)...
FilS2BotS
 
Posts: 149
Joined: Wed May 05, 2010 2:20 am

Re: Hours/Days

Postby kraada » Tue Sep 28, 2010 11:27 am

Ah I see. You'll need to use variables then.

Create var_minutes_per_days_played_minutes and var_minutes_per_days_played_hours with definitions:

var_minutes_per_days_played_hours:
((cnt_minutes / cnt_days_played) / 60) - mod((cnt_minutes / cnt_days_played) / 60), 60)

var_minutes_per_days_played_minutes:
mod((cnt_minutes / cnt_days_played) / 60), 60)

Then use this format expression:

format( '{1}:{2}',
format_number(var_minutes_per_days_played_hours, 0, false, false),
format_number(var_minutes_per_days_played_minutes, 0, false, false))
kraada
Moderator
 
Posts: 54430
Joined: Wed Mar 05, 2008 2:32 am
Location: NY

Re: Hours/Days

Postby FilS2BotS » Tue Sep 28, 2010 3:35 pm

The format expression is not valid and i can not find the way to fix it... ? :?
FilS2BotS
 
Posts: 149
Joined: Wed May 05, 2010 2:20 am

Re: Hours/Days

Postby kraada » Tue Sep 28, 2010 3:57 pm

In the variables or in the stat? The stat's expression is valid - I just tested it. Are you certain you named the variables properly?
kraada
Moderator
 
Posts: 54430
Joined: Wed Mar 05, 2008 2:32 am
Location: NY

Re: Hours/Days

Postby FilS2BotS » Tue Sep 28, 2010 4:37 pm

The Value Expression still : ((cnt_minutes / cnt_days_played) / 60) ???
It write me 0:0
FilS2BotS
 
Posts: 149
Joined: Wed May 05, 2010 2:20 am

Re: Hours/Days

Postby WhiteRider » Wed Sep 29, 2010 3:37 am

The stat's value expression should just be:
cnt_minutes / cnt_days_played

Use the Format Expression to display the hours and minutes separately and formatted.
WhiteRider
Moderator
 
Posts: 54025
Joined: Sat Jan 19, 2008 7:06 pm
Location: UK

Re: Hours/Days

Postby FilS2BotS » Wed Sep 29, 2010 10:33 am

I have those 2 variables:

var_minutes_per_days_played_hours:
((cnt_minutes / cnt_days_played) / 60) - mod((cnt_minutes / cnt_days_played) / 60), 60)

var_minutes_per_days_played_minutes:
mod((cnt_minutes / cnt_days_played) / 60), 60)



The statistic with the value expression:
cnt_minutes / cnt_days_played

And the format expression:
format( '{1}:{2}',
format_number(var_minutes_per_days_played_hours, 0, false, false),
format_number(var_minutes_per_days_played_minutes, 0, false, false))



It still give me 0:0

???
FilS2BotS
 
Posts: 149
Joined: Wed May 05, 2010 2:20 am

Re: Hours/Days

Postby WhiteRider » Wed Sep 29, 2010 11:34 am

I'd forget the variables - use this Format Expression:

format( '{1}:{2}{3}',
format_number( if ( (cnt_minutes / cnt_days_played) < 60, 0, (cnt_minutes / cnt_days_played - 30) / 60 ), 0, false, false),
if ( (cnt_minutes / cnt_days_played) MOD 60 < 10, '0', ''),
format_number((cnt_minutes / cnt_days_played) MOD 60, 0, false, false) )

..and this Value Expression:

(cnt_minutes / 60) / cnt_days_played
WhiteRider
Moderator
 
Posts: 54025
Joined: Sat Jan 19, 2008 7:06 pm
Location: UK

Re: Hours/Days

Postby FilS2BotS » Wed Sep 29, 2010 1:09 pm

TY i added the statistic to the Repository
FilS2BotS
 
Posts: 149
Joined: Wed May 05, 2010 2:20 am

Re: Hours/Days

Postby WhiteRider » Wed Sep 29, 2010 1:32 pm

Cool!
WhiteRider
Moderator
 
Posts: 54025
Joined: Sat Jan 19, 2008 7:06 pm
Location: UK

Previous

Return to Custom Stats, Reports, and SQL [Read Only]

Who is online

Users browsing this forum: No registered users and 0 guests