Register  |  Login


Question

Status: Closed Points: 75 Time: 04:57 - Sep 26, 2007  

dustPuppy

get day difference between two dates in c#?

i need to calculate the day difference between two dates that can be more than a year apart.
I can't seem to figure the right way of doing this in C#.
I mean I can subtract one date from the other, but how do I get the remaining out as number of days?

Answer Discussion
Answer Summaries

 

Q&A System for Websites and Corporate Collaboration

Advertisement

  • Generates significant organic traffic for websites
  • Saves companies money, resources, and time

dustPuppy

Date:: Sep 28, 2007

Time:: 12:59

I found out it was more simple than I thought.
subtracting one date from another returns not a datetime as I thought I saw, but a TimeSpan object.
So you can do this:
TimeSpan difference = endTime.Subtract(startTime);
and then get the days with: difference.Days

Question Answered

This question has been closed, and points have been rewarded to the following experts:

dustPuppy: 75

You're welcome however to comment or give additional information or if you wish, you have the ability to write an Answer Summary for the Summary Area.

Answer this Question

New User

Email:

Upon submission of this form, you will automatically be registered as a Quomon user and we will send your login information to this address

Registered User

Username:

Password:

Forgot Your Password?

No summaries have been submitted yet. Want to be the first?

Answer this Question

New User

Email:

Upon submission of this form, you will automatically be registered as a Quomon user and we will send your login information to this address

Registered User

Username:

Password:

Forgot Your Password?

Ask a Question

Have a new question? Ask!

You have 100 characters to use


Top Experts

View More

Rank

Expert

Points

1.

nidhi

6162

2.

rcastagna

4171

3.

LAGM

3650

4.

PeterNZ

2807

5.

oracleofDelphi

2698

6.

jgivoni

1953

7.

xarcus

1820

8.

gonzalo

1000

9.

Anpanman

812

10.

theDude

695

Become an Expert

Register today to share your knowledge with the community and be recognized and rewarded for your contributions.


Register Here




"Psst, Quomon is a great site. Pass it on."     Tell a Friend  |   Link To Us  |   Save to Delicious  |   Digg! Digg it



Language Options

English:

www.quomon.com

Español:

www.quomon.es