Click here to Skip to main content
15,887,350 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
DateTime dt = "04/20/2015 6:30:00";
DateTime dt = "04/10/2015 6:30:00";

How to get difference in minute for the two values
Plz help friends.......
Posted

1 solution

Try this:

C#
DateTime dt1 = new DateTime(2015,10,4, 6,30,0);
DateTime dt2 = new DateTime (2015,10,4, 6,22,0);

TimeSpan ts = dt2-dt1;
Console.WriteLine("Difference in minutes: {0}", ts.TotalMinutes);
//Result: 8


[EDIT]
Thank you Richard for your valuable suggestion.
 
Share this answer
 
v2
Comments
Richard Deeming 20-Apr-15 11:39am    
That will work if the difference is less than one hour. If it exceeds one hour, you'd need to use TotalMinutes instead. :)
Maciej Los 20-Apr-15 11:52am    
Thank you for suggestion, Richard ;)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900