How do I convert a multiple SSRS dataset calculation into HH:MM:SS - reporting-services

I have totaled up the values from multiple datasets and then divided that by 60 to give me the amount of hours. But how do I go about showing this is as a value of hh:mm:ss
For example - here is my expression:
=(count(Fields!Second_Choice_Options.Value, "Authorisation") * 20 + count(Fields!Second_Choice_Options.Value, "ClaimPaid") * 20 + count(Fields!Second_Choice_Options.Value, "ClaimPended") * 20 + count(Fields!Second_Choice_Options.Value, "General") * 8 +count(Fields!Second_Choice_Options.Value, "Reassessment") * 20 +count(Fields!Second_Choice_Options.Value, "ReserveReview") *3 +count(Fields!Second_Choice_Options.Value, "Trigger") *5 + Sum(Fields!ACD_Calls.Value, "DataSet3") * 6 + Sum(Fields!Extn_Out_Calls.Value, "DataSet3") * 2) / 60
The total answer being 4217. Which then in hours is 70.283 (this is the current value showing) but how do I write the expression so the value is returned as 70:17:00 (70 hours, 17 minutes and 0 seconds)
Thanks
Dan

This code works with times <= 24 hours:
=Format(DateAdd("s", [YourExpressionToObtainMinutes]*60, "00:00:00"), "HH:mm:ss")
So you have to change it a little:
=Format([YourExpressionToObtainMinutes]/60, "00") & ":" & Format(DateAdd("s", [YourExpressionToObtainMinutes]*60, "00:00"), "mm:ss")

Try setting your text box properties to Time, that should help I would expect.

Related

Converting Degrees/Minutes/Seconds to Decimals using MySQL

I'm using MySQL version: 5.7.22
I've got two columns Latitude and Longitude both in Degrees/Minutes/Seconds format that I want to convert to Decimal format ex: 48° 52.250' N to 48.93611111
I have the following script but I'm stuck at how to split the degrees minutes and seconds. I cannot hard-code the values as I've done here left(Latitude,2) since the degrees might have 3 decimals as well
SELECT Latitude,
left(Latitude, 2) +
(TRUNCATE((Latitude - TRUNCATE(Latitude)) * 100) / 60) +
(((Latitude * 100) - TRUNCATE(Latitude * 100)) * 100) / (60 * 60) AS DECIMAL_DEGREES
FROM small_ocean_data
The formula for the conversion is this: D + M/60 + S/3600 * -1 if direction in ['W', 'S'] else 1
Any help would be grateful!
Well if I use this formula of yours: D + M/60 + S/3600
Where I believe D is Degrees and M are Minutes and S are Seconds.
With this select:
select SUBSTRING_INDEX('48° 52.250', '°',1) +
(SUBSTRING_INDEX('48° 52.250',' ',1)/60) +
(SUBSTRING_INDEX('48° 52.250','.',1)/3600);
Or for your database:
select SUBSTRING_INDEX(Latitude, '°', 1) +
(SUBSTRING_INDEX(Latitude ,' ',1)/60) +
(SUBSTRING_INDEX(Latitude ,'.',1)/3600) "DECIMAL_DEGREES"
FROM small_ocean_data;
I get 48.81333333333333
48 + 0.8 + 0.013333333333333334
Here is the DEMO

How do I calculate a percentage value from these two time values

I have two expressions which are calculating across a number of datasets
Expression 1 is as follows:
=Format((count(Fields!Second_Choice_Options.Value, "Authorisation") * 20 + count(Fields!Second_Choice_Options.Value, "ClaimPaid") * 20 + count(Fields!Second_Choice_Options.Value, "ClaimPended") * 20 + count(Fields!Second_Choice_Options.Value, "General") * 8 +count(Fields!Second_Choice_Options.Value, "Reassessment") * 20 +count(Fields!Second_Choice_Options.Value, "ReserveReview") *3 +count(Fields!Second_Choice_Options.Value, "Trigger") *5 + Sum(Fields!ACD_Calls.Value, "DataSet3") * 6 + Sum(Fields!Extn_Out_Calls.Value, "DataSet3") * 2) / 60, "00") & ":" & Format(DateAdd("s", (count(Fields!Second_Choice_Options.Value, "Authorisation") * 20 + count(Fields!Second_Choice_Options.Value, "ClaimPaid") * 20 + count(Fields!Second_Choice_Options.Value, "ClaimPended") * 20 + count(Fields!Second_Choice_Options.Value, "General") * 8 +count(Fields!Second_Choice_Options.Value, "Reassessment") * 20 +count(Fields!Second_Choice_Options.Value, "ReserveReview") *3 +count(Fields!Second_Choice_Options.Value, "Trigger") *5 + Sum(Fields!ACD_Calls.Value, "DataSet3") * 6 + Sum(Fields!Extn_Out_Calls.Value, "DataSet3") * 2) * 60, "00:00"), "mm:ss")
and the time value is 71:45:00
I then have a second expression which is
=System.Math.Floor(Sum(Fields!Staffed_Time.Value) / 3600) - System.Math.Floor(Sum(Fields!Time_in_Lunch.Value) / 3600)- System.Math.Floor(Sum(Fields!Time_in_AUX_1099.Value) / 3600) & ":" & Microsoft.VisualBasic.Strings.Format(Microsoft.VisualBasic.DateAndTime.DateAdd("s", Sum(Fields!Staffed_Time.Value), "00:00"), "mm:ss")
and the time value is 156:39:22
Therefore I need to make a new calculation in a textbox and take 71:45:00 as a percentage of 156:39:22 and then display that as a percentage - which would be 45.5%
How can I do this?
Thanks
Dan
Don't use the two expressions that return a formatted time (i.e.: 70:17:00) but the expressions that return the number of minutes (i.e.: 4217), so you can use this formula in a TextBox with Format property set to p2:
=[YourExpression1ToObtainMinutes]/[YourExpression2ToObtainMinutes]

SSIS convert minutes to HH:MM with derived column

I'm trying to get a derived column that converts the sum of minutes to HH:MM. With the following expression I get the right result when the sum of minutes is less then 24 hours:
SUBSTRING((DT_WSTR,20)
DATEADD(
"minute",
FIELDNAME,
(DT_DBTIMESTAMP)"01/01/2013 00:00:00"
)
,12,5)
When the sum of minutes is more than 24 hours (1500mi)I want it to output like "25:00".
Is there a way to do this in a Derived Column Transformation?
Thank you for your input!
Hours = minutes / 60
FIELDNAME / 60.00
Minutes = whats left over (modulo)
FIELDNAME % 60.00
So try
(DT_STR, 2, 1252) (FIELDNAME / 60.00) + ":" + (DT_STR, 2, 1252) (FIELDNAME % 60.00)
I used this one:
Right("00" +(DT_STR,2,1252)(FIELDNAME / 60),2) + Right("00" + (DT_STR,2,1252)(FIELDNAME % 60), 2)

How To Generate A Random Decimal Value In Mysql

I am trying to generate a random value between 0.01 - 0.50 to enter into mysql. I have 2.7 million rows that I need to execute this on.
Here is my script:
UPDATE FBAInventory SET buyBox = ROUND( 0.01 + RAND( ) * 8,2 );
It is generating values such as 4.20, 3.89 etc. I only want it to span from 0.01 - 0.50 and not to exceed this.
Does anyone know how to do this?
Thanks!
How about...
round(rand() * 0.49 + 0.01, 2);
You can use the floor function to generate a range of random numbers.
FLOOR(RAND() * (<max> - <min> + 1)) + <min>
where the max and min are inclusive. So in your case you would want
FLOOR(RAND() * 1.49 ) + 0.01

Convert and round (Seconds to Minutes) with SQL

I have a field on my table which represents seconds, I want to convert to minutes
Select (100/60) as Minute from MyTable
-> 1.66
How can I get 1 minute and 40 seconds 00:01:40 and then round to 00:02:00 and if 00:01:23 round to 00:01:30
Using Mysql.
There are two ways of rounding, using integer arithmetic and avoiding floating points, a value to the nearest thirty seconds...
((seconds + 15) DIV 30) * 30
(seconds + 15) - (seconds + 15) % 30
The latter is longer, but in terms of cpu time should be faster.
You can then use SEC_TO_TIME(seconds) to get the format hh:mm:ss, and take the right 5 characters if you really need hh:mm.
If you wanted to avoid SEC_TO_TIME(seconds), you can build up the string yourself.
minutes = total_seconds DIV 60
seconds = total_seconds % 60
final string = LPAD(minutes, 2, '0') | ':' | LPAD(seconds, 2, '0')
i am not sure about how to round it but you can convert seconds into time i.e hh:mm:ss format using SEC_TO_TIME(totaltime)
Desired result :
A = 30
B = 60
C = 90
D = 120
select
(25 + 15)-(25 + 15) % 30 as A,
(32 + 15)-(32 + 15) % 30 as B,
(90 + 15)-(90 + 15) % 30 as C,
(100 + 15)-(100 + 15) % 30 as D
Result :
A = 30
B = 30
C = 90
D = 90
I try with this:
select
30* ceil(30/30) as A,
30* ceil(32/30) as B,
30* ceil(90/30) as C,
30* ceil(100/30) as D
Result :
A = 30
B = 60
C = 90
D = 120
Thank you for your help !
You can simply write your own function http://dev.mysql.com/doc/refman/5.0/en/create-procedure.html
But I'd rather do that in a programing language (PHP, Python, C), not on the database side.