Solved

How to find no. of hours between 2 dates in asp.net

Posted on 2011-03-13
2
379 Views
Last Modified: 2012-05-11
I have 2 dates d1 and d2.
in dd mm yyyy hh mm ss format.
How to find the no. of hours between 2 dates.
0
Comment
Question by:searchsanjaysharma
2 Comments
 
LVL 18

Accepted Solution

by:
Ajay Sharma earned 500 total points
ID: 35122247
Use TimeSpan

DateTime dt1 = new DateTime();
        dt1 = DateTime.Now.AddDays(-2);

        DateTime dt2 = new DateTime();
        dt2 = DateTime.Now;

        TimeSpan timeDiff = dt2 - dt1;
        lblMessage.Text = timeDiff.TotalHours.ToString()
0
 

Author Closing Comment

by:searchsanjaysharma
ID: 35122721
ok
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now