Questions tagged [timespan]

An elapsed measurement of time between two events or during which an event, program or a function continues. Also known as a timedelta or a duration.

A timespan is an elapsed measurement of time between two events or during which an event, program or a function continues.

It is also known as a timedelta or a duration in many programming languages.

  • For most intervals of time, this is calculated by:

    EndTime - StartTime
    

    This works especially well for half-open intervals that are used by time-only ranges, or date+time ranges.

  • However, be careful with date-only ranges. Typically these are expressed using fully-closed intervals, such as Jan 1 to Jan 2 to represent two days. This is calculated by:

    EndDate - StartDate + 1
    

See also the and tags.

1171 questions
-3
votes
2 answers

Timespan AM to PM c#

I am working on a project that involves shift work so I need my shifts to display correctly as time moves along. I currently have 3 shifts (shifth = start shifthe = end) as follows. Shift1 8AM-4PM Shift2 4:01PM-12:01AM and Shift3 12:02AM-7:59AM the…
Marcus
  • 97
  • 1
  • 11
-3
votes
2 answers

C# How to calculate days between to dates without using Date/DateTime/TimeSpan?

I've got interview task to do. I need to calculate number of dates between to dates WITHOUT using Date/DateTime/TimeSpan classes to do that. How to do that by using the String class only? Best Regards //vamone
vamone
  • 303
  • 1
  • 2
  • 10
-3
votes
3 answers

Calculate salary between two Datetimes C#

Question: Hi I am wondering if threre is a way to categorize time with a simple xor or somthing like that? Explaination: I have a database table filled with DateTime fields PunchInTime And a PunchOut time and i am trying to get how many hours of a…
-3
votes
1 answer

Conversion from type 'TimeSpan' to type 'String' is not valid

' > System.InvalidCastException: Conversion from type 'TimeSpan' to type 'String' is not valid ' > I have a gridview , i want that the column"duréeCalculée" take like this value "text='<%#…
-3
votes
1 answer

how to convert yearly time data in to specific hourly interval data in R

i have a time series dataset containing 10000 rows with 1 year of data which looks like this 2012-01-01 06:23:02 c d10 2012-01-01 08:12:12 d d2 ........................... 2012-12-31 08:22:24 s d5 it has 3 fields date_time,…
mubarak
  • 77
  • 11
-3
votes
1 answer

What culture does TimeSpan.Parse(String) use?

The doco for TimeSpan.Parse(String) http://msdn.microsoft.com/en-us/library/se73z7b9(v=vs.110).aspx does not explicitly say what culture is used.
Simon
  • 33,714
  • 21
  • 133
  • 202
-3
votes
2 answers

How to find difference between 2 time strings in HHMMSSmmmuuu format in C#

I have two time strings in HH:MM:SS:mmm:uuu format. How to find the difference (time span) between them? string t1="06:37:30:210:111"; string t2="06:38:32:310:222"; I want to find the difference (in terms of time) between t2 and t1 (t2-t1). How to…
Anoop
  • 53
  • 2
  • 3
  • 9
-4
votes
1 answer

C# TimeSpan giving different results than expected

It's a simple task that turned into a confusing situation. 2:20 min when placed in like this TimeSpan(0,2,20) and then TimeSpan.TotallSeconds gives you 140 seconds But when you do the same calculation TimeSpan.FromMinutes(2.20).TotalSeconds it gives…
user13039846
-4
votes
3 answers

add datetime values to previous datetime values

How can I add timedate to already timedate or timespan value recursively? I've tried this but it gives me error: 'A local variable named 'total' cannot be declared in this scope because it would give a different meaning to 'total, which is…
Mubi
  • 11
  • 1
  • 8
-4
votes
1 answer

count the total time of values in textbox. i want to calculate the time of the value

i have some value in text box . i want to calculate the time of that value in text box .means for how long that value is there in the text box. values are of Boolean type . it can be 1 or 0 .i want to calculate the time span of each value also…
-4
votes
3 answers

Converting Total Hours with type (double) to formatted time

I am getting total hour from this code : string date = Request.Form[DFrom.UniqueID]; string date1 = Request.Form[DTo.UniqueID]; ; DateTime start = DateTime.ParseExact(date, "MM/dd/yyyy hh:mm tt", null); DateTime end = DateTime.ParseExact(date1,…
Ali Alzahrani
  • 529
  • 1
  • 6
  • 29
-5
votes
1 answer

How to add minutes to time

Guys I want to add Minutes to time for exemple I have 8:50h and I want to add to it another 8:50h; I have tried time = time.Add(TimeSpan.FromHours(8.5)); // time variable already has 8:50:00 and time it's TimeSpan variable but I got 17:00h (it…
stacj aa
  • 611
  • 2
  • 9
  • 17
-5
votes
2 answers

Time overlap checking with provided start and end time span sets in c#

Time overlap with C#: checking 2 set of start and end date combination over lap checking? "6:00 am" to "4:30 pm" "8:29 am" to "4:30 pm"
-5
votes
2 answers

Timespan function to convert minutes into 8 hour working days

Need to count in C# app, minutes in SLA to show in format : N working days, N working hours, N working minutes current code show up only hours:minutes format: TimeSpan spWorkMin = TimeSpan.FromMinutes(12534); string workHours =…
DarthCSharper
  • 133
  • 1
  • 13
-5
votes
1 answer

convert string from database to double

In my program I am using a database containing a Time (string previousTimeVASN). I have a timer to clock total seconds. i would like to display the sum of previousTimeVASN + the total seconds. I have error showing: "System.FormatException: 'Input…
1 2 3
78
79