## Timespan division by a number

I have a code generating a timespan to calculate a duration of some action. What I want to do is to take that result (the duration) and divide it by a number, any number.

How can I do that?

try

```TimeSpan X = ...;

var Result = X.TotalMilliseconds / WhatEverNumber;
```

For reference see MSDN.

Timespan division by a number, C# (CSharp) System TimeSpan. Divide extracted from open source projects. If the number is greater than 1, then the timestep will 1 then a substep will be� Divide(TimeSpan) Returns a new Double value which is the result of division of this instance and the specified ts. Divide(Double) Returns a new TimeSpan object which value is the result of division of this instance and the specified divisor.

You can use ticks of the original timespan:

```var res = new TimeSpan(origSpan.Ticks / aNumberAnyNumber);
```

TimeSpan.Divide Method (System), Division(TimeSpan, TimeSpan) Returns a new Double value which is the result of division of t1 instance and the specified t2. Division(TimeSpan, Double) Returns a new TimeSpan object which value is the result of division of timeSpan instance and the specified divisor.

Use one of the `Total*` properties of the `TimeSpan` which are numbers.

I.e. if you're running five iterations of some code which you measure, then you can use

```myTimeSpan.TotalMilliseconds / 5
```

to get the average number of milliseconds per iteration. You can use the `Ticks` to get the underlying value and construct a new `TimeSpan` from the divided result.

TimeSpan.Division Operator (System), As we saw in the video, the first step to calculating a timespan in lubridate is to make an interval, then use division to convert the units to what you want (like weeks (x) or months (x)). The x refers to the number of time units to be included in the period. In this exercise, you'll calculate timespans with the baker_time data we just made.

```TimeSpan ts = ...
TimeSpan result = TimeSpan.FromTicks(ts.Ticks / divisor);
```

TimeSpan.Divide, System C# (CSharp) Code Examples , Compares this instance to a specified TimeSpan object and returns an integer that indicates whether this instance is shorter than, equal to, or longer than the TimeSpan object. Divide(Double) Returns a new TimeSpan object which value is the result of division of this instance and the specified divisor. Divide(TimeSpan)

If you want to end up with a new TimeSpan that is a fraction of the old:

```TimeSpan now = DateTime.Now.TimeOfDay;
TimeSpan halfOfNow = new TimeSpan(now.Ticks / 2);
```

Agree that best approach is to use seconds in TimeSpan and then utlize function TotalSeconds to get integer value and be able to divide by 60 to get minutes of whatever you need.

Returns TimeSpan. An object that represents value.. Examples. The following example creates several TimeSpan objects using the FromTicks method. // Example of the TimeSpan::FromTicks( __int64 ) method. using namespace System; void GenTimeSpanFromTicks( __int64 ticks ) { // Create a TimeSpan object and TimeSpan string from // a number of ticks.

Examples. The following example creates several TimeSpan objects using the FromSeconds method. // Example of the TimeSpan::FromSeconds( double ) method. using namespace System; void GenTimeSpanFromSeconds( double seconds ) { // Create a TimeSpan object and TimeSpan string from // a number of seconds.

Hi all, I am looking for an accurate way to convert a TimeSpan.Days value to years and month. I know I can get approximate values by dividing the number of days by 365 to get the years and then dev

• P\roblem with the default method is that it returns `double` instead of `TimeSpan` if you attempt to divide `TimeSpan` by `TimeSpan`. See other answers.