Converting seconds to hours and minutes - seconds

I am a newbie in C# and having trouble converting seconds to hours and minutes. I manage to extract the value from an xml and have it place in a text box. I am stuck when trying to convert the value on the textbox which is in seconds to another textbox that will give the result in hh.mm.
I have look at the various example even tried to use the Timespan method but the result is not appearing.
Hope you can guide me on the required code to have the desired result to the other text box. The value for seconds is not fixed. It will changed each time a request is made as it is a total time from point A to point B.

Related

SSRS - How to AVG then format a number

I'm trying to get the average handle time per call to display as HH:MM:SS.
What I can't seem to figure out is how to take the AVG(Field) and make it HH:MM:SS. I can either A) avg and get the a decimal number which represents seconds or format total seconds for all calls in HH:MM:SS. but can't seem to marry the two. I'm sure it's simple but can't find anything on here that works.
This was one of my attempts that didn't work. "=Format(Avg(Fields!AHT.Value), 'HH:MM:SS')"
Any help would be greatly appreciated!
You should be able to do something like ...
=DATEADD(DateInterval.Second, AVG(Fields!AHT.Value), Today())
then format this textbox as Time in the textbox properties, under 'Number' or use the format code T
This gives this result..
All the expression does is take Today() which is only the date (therefore the time is 00:00:00) and then add the average number of seconds to it. So the actual result is today's date plus the time we want. Then format the textbox as time only, to hide the date portion.

Need a proper input mask for a time field in Microsoft Access

My table field is date/time and formatted like this:
mm/dd/yyyy hh:nn:ss
I want the user to see this (with the space appearing between date and time
__/__/__ __:__:__
I want an input mask that demands:
Either 1 or 2 digits for the month
Either 1 or 2 digits for the dat
All 4 digits for the year
SHOWS the space but just jumps over it for the user
Either 1 or 2 digits for each of Hours, Minutes and Seconds
Further, when setting up a DB, is it just smarter to have two separate fields for Date and Time. A collegue encouraged me to break them out ... seems sensible?
00/00/0000##00:00:00
See the outcome in the image
Controlled user input is not an easy task in Access, as it is optimised for the opposite: To be tolerant and accept many input sequences for date and time.
For the cases where controlled input is mandatory, I've written two articles including full code (too much to post here) and demo, that may give you some ideas:
Entering ISO formatted date with input mask and full validation in Microsoft Access
Current code at VBA.DateEntry.
and
Entering 24-hour time with input mask and full validation in Microsoft Access.
Current code at VBA.TimeEntry.

MS Access Time Format changing from hh:nn to h:nn

I'm having this frustrating problem in Access. I have a form with a text box control, formatted as hh:nn. However, if the time has a single digit hour, such as the time 08:45, when I leave the text box Access seems to change the format to h:nn, displaying only 8:45.
This causes difficulties the next time a user enters the text box and tries to change the time or even just leave the time as is.
Why is Access displaying the hh:nn format as h:nn? How can I fix this?
I had the same issue because of "the regional Long Time format" as explained in the below reference.
Reference
My regional Long Time format was set to "h:mm:ss tt". I changed it to "hh:mm:ss tt", exited Access, restarted and reopened the test database I was using, and now the dates, in table and form, are displaying the hour with the leading zero.

Converting timer format hh:mm to decimal format hh.decimal(mm) in Business Objects

The aim is to create a new data column based on a current time formatted colum.
For example I want to have 4:20 -> 4.33. I can't find a way of manipulating the time format to extract the hours and minutes seperatly to use hours + (minutes / 60).
Any help appreciated. Thank you.
To pick specific parts out of a datetime object you need to use the FormatDate() function. It returns a string which you need to convert to a number with the ToNumber() function before adding the hours and minutes together. So let's create a few variables...
Current DateTime=CurrentDate()
Hours=ToNumber(FormatDate([Current DateTime];"hh"); "##")
Minutes=ToNumber(FormatDate([Current DateTime];"mm"); "##")
Hours Minutes Decimal=[Hours] + ([Minutes]/60)
If you want to put this all together in one variable you can certainly do that...
Hours Minutes Decimal All in One=ToNumber(FormatDate(CurrentDate();"hh"); "##") + (ToNumber(FormatDate(CurrentDate();"mm"); "##")/60)
To locate documentation on what values correspond to which parts of the datetime value do the following...
Navigate to the FormatDate() function in the Variable Editor.
Click on "More on this function" in the lower right corner.
Click on "Custom Formats"

MS-Access Web DB "type mismatch" when setting date as string?

This is specifically for MS-Access Web Databases (requires Sharepoint hosting) which has many limitations compared to their client counterparts, like no VBA, instead you get form macros and data macros to manage data.
I've run into a weird bug on one of my applications. I have a query used to check stock levels against a "minimum stock level" also saved in the table. The query is pretty intense and there are over 4,000 records now to check against. These querys normally take about 75s. So I have made a little label that gets updated every time the form is loaded showing the time and date the query was last run, and the duration in seconds it took. (so users can see how fresh the data is and decide if it needs to be run again)
Now, the weird thing is it works fine in my Access client, but when I sync my changes to the server and try it in a web browser I get a "type mismatch" error. A small table is used to store the start and end times whenever the query is run, that's how I get the timestamp data. These fields are in a "Date/Time" format, obviously. But it seems the problem here is changing the date format to a string format so it can be put in a label on the form. The Access client seems perfectly capable of doing this, while the web client stumbles and falls.
My problem is, how do I change data in a date/time format to a string format in a Web database? I can't figure out how to do this. The tools are so limited. I may have to end up answering my own question here but I'm posting this for others just in case.
To return a value from a data macro as string, you have to format the internal date/time format as a string. In Access an internal date/time value is a double number with the integer part as number of days since 1900, and the “decimal” time part is a fraction of 24 hours. Unfortunately if you simply wrap the date/time in the str$() function we had for 20+ years, then you get something JUST like if you type this into the debug window:
? cdbl(now())
41955.5478587963
The solution is to simply pull out each part. And “nice” is while in few cases a data macro will cast the data type, it does in this case and thus the STR$() command is not required.
The expression you thus can use is this:
Month([d]) & "/" & Day([d]) & " Time = " & Hour([d]) & ":" & Minute([d])
So say to pluck out the VERY LAST start time column from say a invoice table, since we don’t have a dmax(), then we simply sort the table in the order we want and pull out the first row.
Our data macro will thus look like:
Note how in above I simply typed in the SQL and SET the order on the date/time column. I want the MOST recent invoice start date and time. For those new to SQL, then I suggest you build a query in the query builder and specify a query in above lookup feature, since many are not "comfortable" typing in free hand SQL as I did above.
Now, in your browser side (UI) macro, you can use this code:
The above returns a formatted string that you can stuff into a text box, or as per above code change the caption of a label.
Unfortunately with silly problems like this, it becomes a path-of-least resistance thing.
Since my intended result was simply to get "a timedatestamp from a table to show up on a form (so users could see when a query was last run)", this became redesigning my form in Access to be a text field instead of a label. Text fields can be adjusted to accept "Time/Date" formats, so this is exactly what I did, it now pulls the timestamp data directly from the last record of the table and requires no extra formatting to appear in the web browser. I redesigned the text field to appear and function more like a label, and my desired function was achieved.
However, since my question specifically asks, "how do you change a time/date format into a string format in a Web db?", I will leave it here in case someone actually does solve it.