Connecting Tech Pros Worldwide Forums | Help | Site Map

Date diff help please,in c#

Raghu Raman
Guest
 
Posts: n/a
#1: Nov 18 '05
Hi

I want to find the difference between 2 dates in terms of year.It is
confusng in msdn.could u help me on that.

for ex,
int year=datediff("y",date1,date2)//of course it is in VB.

--------------
COULD U PLS TELL ME HOW TO DO IT IN C#.Net

With sincerely
Raghuraman(a drop in the ocean).



*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Ben Lucas
Guest
 
Posts: n/a
#2: Nov 18 '05

re: Date diff help please,in c#


int year = date1.Year - date2.Year;

--
Ben Lucas
Lead Developer
Solien Technology, Inc.
www.solien.com

"Raghu Raman" <raghuraman_ace@rediffmail.com> wrote in message
news:%23o3g1wRtEHA.636@TK2MSFTNGP09.phx.gbl...[color=blue]
> Hi
>
> I want to find the difference between 2 dates in terms of year.It is
> confusng in msdn.could u help me on that.
>
> for ex,
> int year=datediff("y",date1,date2)//of course it is in VB.
>
> --------------
> COULD U PLS TELL ME HOW TO DO IT IN C#.Net
>
> With sincerely
> Raghuraman(a drop in the ocean).
>
>
>
> *** Sent via Developersdex http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it![/color]


Raghu Raman
Guest
 
Posts: n/a
#3: Nov 18 '05

re: Date diff help please,in c#


HI,Lucas,

Thx for that.I ll try that.But i hope it ll give the diff between two
date's year.i am expecting the diff between two dates which should
consider day,month,year into account and will have to produce the diff
in terms of years.


could u pls tell me that.


With Regards
Raghu.





*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Kevin Spencer
Guest
 
Posts: n/a
#4: Nov 18 '05

re: Date diff help please,in c#


Check out the DateTime.Subtract() method.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
I get paid good money to
solve puzzles for a living

"Raghu Raman" <raghuraman_ace@rediffmail.com> wrote in message
news:uEF6aqYtEHA.1272@TK2MSFTNGP12.phx.gbl...[color=blue]
> HI,Lucas,
>
> Thx for that.I ll try that.But i hope it ll give the diff between two
> date's year.i am expecting the diff between two dates which should
> consider day,month,year into account and will have to produce the diff
> in terms of years.
>
>
> could u pls tell me that.
>
>
> With Regards
> Raghu.
>
>
>
>
>
> *** Sent via Developersdex http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it![/color]


Closed Thread