About
Pricing
Community
Teams
Start Free Trial
Log in
starlite551
asked on
9/8/2010
Which is the best way to find Date difference between two dates in C#?
Please submit a code snippet which is most efficient one.. I know about TimeSpan Class Method is there any other method thats more effective?
C#
Programming Languages-Other
4
2
Last Comment
existenz2
8/22/2022 - Mon
rockiroads
9/8/2010
Not that I know off. I thought it better to use what is available in dotnet and for c# that seems to be it.
A little discussion on that here including an alternative using vb namespaces
http://www.c-sharpcorner.com/UploadFile/DipalChoksi/DateDiff_CS_DC09132006172429PM/DateDiff_CS_DC.aspx
joriszwaenepoel
9/8/2010
dim date1 as datetime = ...
dim date2 as datetime = ...
dim datediff = date2.subtract(date1)
This gives you a TimeSpan object with all the information. What makes you think this is not efficient?
SOLUTION
Naman Goel
9/9/2010
THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
ASKER CERTIFIED SOLUTION
existenz2
9/13/2010
THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Your help has saved me hundreds of hours of internet surfing.
fblack61
A little discussion on that here including an alternative using vb namespaces http://www.c-sharpcorner.com/UploadFile/DipalChoksi/DateDiff_CS_DC09132006172429PM/DateDiff_CS_DC.aspx