Click here to Skip to main content
15,886,570 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello ,

how to calculate time difference between AM and PM with date in asp.net
Ex.
Start date="17/06/2015 05:00:00 AM"
End Date="19/06/2015 11:00:00 AM"

Output should be : 2 Day 06:00:00 Hours

Please Help me..

Thanks :-)
Posted

1 solution

You need to use the TimeSpan structure.

C#
DateTime startDate = DateTime.Parse("17/06/2015 05:00:00 AM");
DateTime endDate = DateTime.Parse("19/06/2015 11:00:00 AM");

// Difference in days, hours, and minutes.
TimeSpan ts = newDate - oldDate;

//Format the TimeSpan as you see fit
Console.WriteLine(ts.ToString());
 
Share this answer
 
Comments
Dnyaneshwar Sable 22-Jun-15 1:39am    
Thanks.. its working...

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