I'm trying to figure out the proper syntax to converting a total of minutes to show properly. For example: if something shows 65 minutes I want it to show 1:05.
What I have been messing with is as follows:
Format(Round(DateDiff("n",[StartDate],[DateCompleted]),2),"Short Time")
The query has totals turned on as this field is set to Expression. I'm getting strange results with the current criteria.
I'm sure there is something simple I'm missing but I haven't been having much luck.
Thanks!!!
As long as you won't exceed 24 hours, you can do it straight:
Duration: Format([DateCompleted]-[StartDate],"Short Time")
Related
I am very new to data analytics and I need some help troubleshooting a SQL error I got. So, I have a column in this table which transferred over from Excel to SQL as a string type rather than a time piece of data. I want to make it into a time type so i can further analyze it.
So, I did the attached query to try and change the type of data using the CAST function. . However, it could not complete the query thanks to an outlier in the data set I have yet to clean the data and this was one of my first steps to so, but how do I remove this particular row that contains the invalid time string so the query can actually work? Or is there a better way to convert this entire column from text string to time?
BigQuery Time types adjust values outside the 24 hour boundary - 00:00:00 to 24:00:00; for example, if you subtract an hour from 00:30:00, the returned value is 23:30:00.
Based on your screenshot it looks like you are storing a duration? So 330 hours, 25 minutes and 55 seconds?
You would probably be best using timestamp, converting the hours to days and adding the remainder to your minutes and seconds.
You can then cast the resulting string to timestamp.
Edit
A much simpler solution is just cast('330:25:55' as interval) - thanks to #MatBailie
I looked through online solutions for this, none worked for me so I'm posting here. I have separate date and time columns, both stored as integers. I am able to convert the date column to DATE, but not for the Time column. The column value is: 52700, when using TO_TIME(TO_CHAR(OHCRTM)) I get 14:38:20 but it should be 07:27:00. I've tried various formatting (TO_TIME(TO_CHAR(OHCRTM),'HH24.MI.SS') but I get a 'cannot parse' error. Any idea how I can get the correct time?
14:38:20 is the right answer, unless you can give us the logic that would make it 07:27:00.
52700 seconds are exactly 14 hours, 38 minutes, and 20 seconds.
Another option to read 52700 would be a time without the colons, ie 05:27:00. To parse it like that the needed SQL is:
select to_time(52700::string, 'HHMISS');
I guess 05 becomes 07 after a timezone conversion then?
Hi all this is my first time posting on Stack Overflow.
I'm trying to plot a chart that displays names of some schedules we run, and their total run time duration. What I'm trying to achieve is to show our 5 slowest schedules. SQL data output is something like this:
SQL Output
Note for elapsed above, this is currently cast as TIME, however I have also had it in the format of 03:19:02 without the milliseconds afterwards as well by using CONVERT VARCHAR 108.
My graph
In the screenshot above you can see the schedule numbers on the left and the elapsed time on the bottom.
Things I have tried so far:
Setting the format under number to HH:mm or HH:mm:ss. Neither of these work, when I do this it results in this:
My attempt at custom Number formats
How it looks after I save the number format
As you can see it just plots a ridiculous HH:mm continuously on the bottom axis as opposed to an actual time. This happens whether my data is plotted as convert varchar 108 or CAST as TIME.
I've also attempted to go under Axis Options and changed Interval type to Hours or days or minutes etc, if I try any of those the axis just disappears as below:
Interval Type Changed to Hours
Interval Type Changed to Hours output with disappearing axis
Let me know what I'm doing wrong in the above team! Thank you!
It looks like you are not showing the actual duration but a count (which is always 1).
Look under Chart Data / Values and make sure your aggregate is e.g. a MAX and not a COUNT.
In our database time is stored in seconds. I need to pull the time out and convert into hours with a max of 2 decimal places.
I have the following
sum (CAST(vt.TIMEINSECONDS AS decimal(10,2))/3600) as AMOUNT_TAKEN
for most part it works, but sometimes it shows 39.9999998 instead of 40 hrs and in the reports i'm running due to the time being like that its causing issues. How can i get it to show 40
CAST the result after division
CAST(SUM(vt.TIMEINSECONDS)/3600.0 AS decimal(10,2)) as AMOUNT_TAKEN
I found the right way to the round the value for my issue.
sum (CAST(ROUND(vt.TIMEINSECONDS/60.0/60.0,2)AS decimal (6,2)))
Thank you to all that helped.
I'm creating a data table using DataTables.net where a column contains the cumulative running hours of an event. I'm simply adding to the hours each time, so I have for example:
40:34:30
which is 40 hours, 34 minutes, 30 seconds.
My problem is I want to order this column by hours, and I haven't been able to find anything that supports this from Moment.js. Ideally I imagine it would be something like "HHH:mm:ss", or something like that. As it stands, the column recognises the fields as strings, so 0:12:34 is appearing above anything else in descending order despite only being 12 minutes long.
You can sort HH:mm:ss by re-formating it to seconds before sorting.
moment.duration('40:34:30').asSeconds;
gives you 146070. Then simply use seconds in your sorting script.
here is the solution: jsFiddle
And if you really need just the hour part; use Math.floor: jsFiddle