timespan

Formatting Timespans within Business Objects Desktop Intelligence (BO Deski)

Can anyone tell me how to format a given number of seconds (for example 16742 seconds) in a human readable form (for example 1d 5h 2m 13s) using a BO field formula or from within a T-SQL SELECT statement (where the Duration as Seconds is from a SUM aggregate)? ...

.NET How to serialize a TimeSpan to XML

I am trying to serialize a .NET TimeSpan object to XML and it is not working. A quick google has suggested that while TimeSpan is serializable, the XmlCustomFormatter does not provide methods to convert TimeSpan objects to and from XML. One suggested approach was to ignore the TimeSpan for serialization, and instead serialize the result...

Clean way to reduce many TimeSpans into fewer, average TimeSpans?

I have a C# Queue<TimeSpan> containing 500 elements. I need to reduce those into 50 elements by taking groups of 10 TimeSpans and selecting their average. Is there a clean way to do this? I'm thinking LINQ will help, but I can't figure out a clean way. Any ideas? ...

What is the most intuitive, usable way of entering a time of day or a duration?

I'm building a line-of-business application in Silverlight and need to get the user to edit two .NET TimeSpan values. One is a time of day (relative to midnight) and the other is a duration. Currently I'm using two TextBoxes, formatted as hh:mm. This is pretty straightforward, but it could definitely be improved. I've observed people usi...

What is the best way to represent a timespan in SQL Server CE?

Specifically speaking I only need hours:minutes but say I have a .NET TimeSpan object, how should I store that in a SQL(CE) database? ...

Timespan formatting

How do you elegantly format a timespan to say example "1 hour 10 minutes" when you have declared it as : TimeSpan t = new TimeSpan(0, 70, 0); ? I am of course aware that you could do some simple maths for this, but I was kinda hoping that there is something in .NET to handle this for me - for more complicated scenarios Duplicate of ...

How do I convert a TimeSpan to a formatted string?

Exact Duplicate Timespan formatting First question here: I have two DateTime vars, beginTime and endTime. I have gotten the difference of them by doing the following: TimeSpan dateDifference = endTime.Subtract(beginTime); How can I now return a string of this in hh hrs, mm mins, ss secs format using C#. If the difference was 0...

Mapping a database value to a TimeSpan using dbml

I need to store a time offset in a database column (for example, 12:25 AM, just the time, no date). I would like to use the nice data visual modeling capabilities in Visual Studio 2008 to generate dbml and the code to go with it. The database is Sql Server 2005. Since a TimeSpan is essentially an Int64 (aka long) containing the number ...

How to display Duration only Hours:Minutes:Second in Gridview Asp.Net by using LINQ to SQL?

Hi again Guys, I want to display the duration only Hour, Minutes, and Second in data Gridview by Subtract TimeCheckOut from TimeCheckIn in ASP.NET using LINQ to SQL Here is code behind: Dim db = new MyDataContext Dim user = from u in db.Employees select IDNumber = u.IDNumber, _ FirstName = u.firstName, LastName = u.lastName,...

How to generate double value from TimeSpan

Hi, I have to calculate the relative time which is TimeSpan relativeTime = currentTime.Subtract(startTime); Next I would like to convert relativeTime to double value which should be consisted of seconds and milliseconds (seconds.milliseconds). Does anyone know what is the best way to generate such double value from time difference? ...

Computing average values over sections of date/time.

Problem: I have a database of sensor readings with a timestamp for the time the sensor was read. Basically it looks like this: Sensor | Timestamp | Value Now I want to make a graph out of this data and I want to make serveral different graphs. Say I want one for the last day, one for the last week and one for the last month. The reso...

How long is a .NET DateTime/TimeSpan tick?

How long is a .NET DateTime/TimeSpan tick? ...

Handle negative time spans

in my output of a grid i calculate a TimeSpan and take its TotalHours ex. (Eval("WorkedHours") - Eval("BadgedHours")).TotalHours goal is to show this TotalHours as : 39:44 so. First value 7.5 to 07:30 no problem.. but if its negative! I can create a TimeSpan object from Hours with TimeSpan.FromHours( (Eval("WorkedHours") - Eval("Ba...

TimeSpan to friendly string library (C#)

Duplicate: This is one of the earliest question on StackOverflow posted by Jeff. http://stackoverflow.com/questions/11/how-do-i-calculate-relative-time Does anyone know of a good library (or code snippet) for converting a TimeSpan object to a "friendly" string such as: Two years, three months and four days One week and two days (...

SSRS using TimeSpan object in chart series.

I need to use a TimeSpan object as the datasource for a chart in reporting services. Unfortunatley i get the error: Series data points do not support values of type "System.TimeSpan"... Is the some magic trick to work around this limitation? ...

Objective-C timespan

In C#, if I wanted to parse out a string into a date and timespan, I'd do something similar to the following: String input = "08:00"; DateTime time; if (!DateTime.TryParse(input, out time)) { // invalid input return; } TimeSpan timeSpan = new TimeSpan(time.Hour, time.Minute, time.Second); My Google-Fu has been less than desir...

PHP - Best way to work with timespans?

Is there a preferred class or method for working with timespans in PHP? The primary functionality I am interested in is checking if a date is within the timespan, or generating timestamps for the lower and upper limits. ...

C# best way to compare two time of the day

Hello, I woulld like to know if a specified time of the day is passed. I don't really like the way I am doing : private static readonly TimeSpan _whenTimeIsOver = new TimeSpan(16,25,00); internal static bool IsTimeOver() { return DateTime.Now.TimeOfDay.Subtract(_whenTimeIsOver ).Ticks > 0; } How do you do ? ...

Is TimeSpan unnecessary?

EDIT 2009-Nov-04 OK, so it's been a little while since I first posted this question. It seems to me that many of the initial responders failed to really get what I was saying--a common response was some variation on "What you're saying doesn't make any sense"--and so I've made some handy diagrams to really illustrate my point. When we ...

Is it possible to measure a timespan that could span over several machine restarts not using the DateTime class???

Hi, I have a bit of a strange problem. I'd like to be able to measure a timespan independently of the system datetime. We basically have a system with one central server and multiple local servers which are constantly synchronising with the central server. Objects on the central server are only valid for a specified time period, e.g....