timespan Questions
3
Solved
I am using .Net Core 3.0 and have the following string which I need to deserialize with Newtonsoft.Json:
{
"userId": null,
"accessToken": null,
"refreshToken": null,
"sessionId": null,
"cooki...
Claro asked 8/10, 2019 at 9:35
9
Solved
I have a collection of objects that include a TimeSpan variable:
MyObject
{
TimeSpan TheDuration { get; set; }
}
I want to use LINQ to sum those times.
Of course, (from r in MyCollection selec...
3
Solved
The below code works fine :
DateTime d1 = DateTime.Now;
DateTime d2 = DateTime.Now.AddDays(-1);
int d3 = (int)(d1 - d2).TotalDays;
But what if I define DateTime as DateTime? :
DateTime? d1 = Da...
Molybdic asked 23/7, 2016 at 12:28
11
Solved
In my application, a user enters two dates. A scheduled start date, and a scheduled end date. We have to take those dates, and populate 4 fields, based on the difference.
So, lets say he selects 1...
5
Solved
I want to achieve the converse of this, that is, I want to convert a string with format hh:mm tt to a TimeSpan with zeroed seconds.
For example, 09:45 pm is converted to 21:45:00.
6
Solved
I've seen these questions but both involve methods that aren't available in the CellStyle Format value. I only want to show the hours and minutes portion (16:05); not the seconds as well (16:05:13)...
Chancroid asked 2/9, 2010 at 14:9
6
Solved
How to parse string like 30:15 to TimeSpan in C#? 30:15 means 30 hours and 15 minutes.
string span = "30:15";
TimeSpan ts = TimeSpan.FromHours(
Convert.ToDouble(span.Split(':')[0])).
Add(TimeSpa...
2
Solved
I want to be able to show minutes and seconds in a textbox. The TextBox is bound towards a property, which is a TimeSpan. In the textbox, the default is : "00:00:00".
This works fine, but...
1
I have a TimeSpan property
public TimeSpan Time { get; set; }
Currently using swagger to test API
Trying to figure out what value value to pass here
"time": {},
Tried:
"time": {"01:01:01"},
...
Soapwort asked 10/3, 2020 at 17:30
27
Solved
In C#/.NET TimeSpan has TotalDays, TotalMinutes, etc. but I can't figure out a formula for total months difference. Variable days per month and leap years keep throwing me off. How can I get TotalM...
3
Solved
The following code
Console.WriteLine("{0:%h} hours {0:%m} minutes",
new TimeSpan(TimeSpan.TicksPerDay));
produces this output:
0 hours 0 minutes
What I would like is this output:
24 h...
Honan asked 18/4, 2011 at 14:0
10
Solved
I am trying to store a .Net TimeSpan in SQL server 2008 R2.
EF Code First seems to be suggesting it should be stored as a Time(7) in SQL.
However TimeSpan in .Net can handle longer periods than...
Allege asked 14/12, 2011 at 11:36
4
Solved
I have items with the properties :
public int ClientId {get;set;}
public DateTime StartDateTime{get;set;}
public DateTime EndDateTime{get;set;}
And I want to calculate the total of the differen...
6
Solved
This is a bit wierd. Parsing a text field with a valid timespan fails if I try to be precise!
const string tmp = "17:23:24";
//works
var t1 = TimeSpan.Parse(tmp);
//fails
var t2 = TimeSpan.ParseEx...
7
Solved
I'm doing some math with the Timespans in .Net, and occasionally the sum results in a negative Timespan. When I display the result I am having trouble formatting it to include the negative indicato...
Impostume asked 11/7, 2010 at 17:2
5
6
Solved
in c# i have time in format hhmmss like 124510 for 12:45:10 and i need to know the the TotalSeconds. i used the TimeSpan.Parse("12:45:10").ToTalSeconds but it does'nt take the format hhmmss. Any ni...
4
Solved
How can I format a TimeSpan object to look like a time zone offset, like this:
+0700
or
-0600
I'm using GetUtcOffset to get an offset, and its working, but its returning a TimeSpan object.
1
Solved
I have a WebAPI (written in C#), a POST-method accepting a complex object with a System.TimeSpan-Property named TriggerDelay, and a React Native application from where I am passing this object in J...
Wilscam asked 25/8, 2020 at 23:18
7
Solved
Using Date.js already, but can also use another library if necessary.
Not sure what is the best way to work with time deltas. Specifically, I want to display the time that has elapsed between now ...
Matrimonial asked 12/1, 2013 at 20:24
6
Solved
I have a class with 2 date properties: FirstDay and LastDay. LastDay is nullable. I would like to generate a string in the format of "x year(s) y day(s)". If the total years are less than 1, I woul...
Pubes asked 11/4, 2013 at 20:11
14
Solved
Is it ever OK to use Environment.TickCount to calculate time spans?
int start = Environment.TickCount;
// Do stuff
int duration = Environment.TickCount - start;
Console.WriteLine("That took &q...
8
Solved
I want to display the elapsed time between two dates in a string.
Let's say I have the following code:
DateTime date1 = DateTime.Now();
System.Threading.Thread.Sleep(2500);
DateTime date2 = DateT...
Ferbam asked 23/8, 2010 at 7:30
10
Solved
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
(It's for a doc...
3
Solved
I'm trying to find a way to call a WCF method using JSON and pass a TimeSpan as parameter but I always receive a "Bad request" response from the service.
Here is a snippet code service interface:
...
© 2022 - 2024 — McMap. All rights reserved.