Click here to Skip to main content
15,891,864 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have two datetime objects and I want to get the number of days between them.

I used datetime.subtract() and return it in time span'
Time span returns only the number of days without consideration to the differance between months.
Posted
Updated 18-Aug-10 4:48am
v2
Comments
Dalek Dave 18-Aug-10 10:49am    
Minor Edit for Readability.

1 solution

This works fine for me:
C#
static double DiffDays(DateTime dt1, DateTime dt2)
{
    return (dt1 - dt2).TotalDays;
}

:)
 
Share this answer
 

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