I want to Calculate TimeFKFeroz Khan11yAsked Dec 20, 2015, 6:52 AM EST4 answersShareLinkedInXCopy linkSave Dear, How can i calculate time through c# with below date and time.. from - 20/12/2015 2:22:33.609000000 PM to 20/12/2015 2:55:33.609000000 PM = Result Time..
I want to Calculate TimeFKFeroz Khan11yAsked Dec 20, 2015, 6:52 AM EST4 answersShareLinkedInXCopy linkSave Dear, How can i calculate time through c# with below date and time.. from - 20/12/2015 2:22:33.609000000 PM to 20/12/2015 2:55:33.609000000 PM = Result Time..
Vinoth RajendranRank #74 · 25K reputation11y agoPosted Dec 20, 2015, 7:59 AM EST0HI,use the TimeSpan get the difference TimeSpan timediff = currentDate - oldDate0
Rajeesh MenothRank #118 · 18.4K reputation11y agoPosted Dec 20, 2015, 6:27 PM EST0Hi, System.DateTime firstDate = new System.DateTime(2000, 01, 01);System.DateTime secondDate = new System.DateTime(2000, 05, 31);System.TimeSpan diff = secondDate.Subtract(firstDate);System.TimeSpan diff1 = secondDate - firstDate;String diff2 = (secondDate - firstDate).TotalDays.ToString();MessageBox.Show(diff1.ToString ()); Reference : http://csharp.net-informations.com/statements/csharp-date-difference.htm 0
Raja TRank #685 · 3.5K reputation11y agoPosted Dec 20, 2015, 6:47 PM EST0Hi Khan, Try like using System.Globalization; string StartTime = "08:00 AM"; string EndTime = "04:00 PM"; DateTime start = DateTime.ParseExact(StartTime, "hh:mm tt", CultureInfo.InvariantCulture); DateTime end = DateTime.ParseExact(EndTime, "hh:mm tt", CultureInfo.InvariantCulture); TimeSpan diff = end - start; Console.WriteLine("Total diff Hours :" + diff); Console.WriteLine("Total diff Mints :" + diff.TotalMinutes);0Ravi PatelRank #439 · 5.7K reputation11y agoPosted Dec 20, 2015, 7:17 PM EST0Hi , Check this http://stackoverflow.com/questions/2821040/how-do-i-find-the-time-difference-between-two-datetime-objects 0Join to answer this questionEvery answer you publish earns 20 SHARP.Create free accountSign inKnow the answer?Answer a question in the forums and earn +20 SHARP for every answer.See unanswered questionsForumsTop experts01Arun PottiAnswers in the forums20answers02Tahir AnsariAnswers in the forums5answers03Kamlesh KumarAnswers in the forums5answers04Sam HobbsAnswers in the forums4answers05Željko PerićAnswers in the forums3answers?YouYour name goes here.Every answer: 20 SHARP.JoinFull leaderboard →2026DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Ravi PatelRank #439 · 5.7K reputation11y agoPosted Dec 20, 2015, 7:17 PM EST0Hi , Check this http://stackoverflow.com/questions/2821040/how-do-i-find-the-time-difference-between-two-datetime-objects 0
Vinoth RajendranRank #74 · 25K reputationPosted Dec 20, 2015, 7:59 AM EST
Rajeesh MenothRank #118 · 18.4K reputationPosted Dec 20, 2015, 6:27 PM EST
Raja TRank #685 · 3.5K reputationPosted Dec 20, 2015, 6:47 PM EST
Ravi PatelRank #439 · 5.7K reputationPosted Dec 20, 2015, 7:17 PM EST
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questionsTop experts