0

Hi,
I am using c#.
I have a problem of finding the difference between 2 dates in terms of year,month and day.
For example Finding the difference of 2 dates(mm/dd/yy).
date1=12/3/2010
date2=3/5/2011

I used the following code

int year=date2.Year-date1.Year;
int month=date2.Month-date1.Month;
int day=date2.Day-date1.Day;

The output I am getting is
1 year 3 months 2 days.

But the actual output is

0 year 3 months 2 days.

How will I solve this?please help me..

Thanks

3
Contributors
4
Replies
5
Views
6 Years
Discussion Span
Last Post by divyakrishnan
0

use asp.net datediff function for finding date difference between two dates

DateDiff( DateInterval, Time1, Time2, [firstDayOfWeek], [firstDayOfYear] )

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.