Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > .NET > .NET 1.0 and Visual Studio.NET > VS.NET 2002/2003
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
VS.NET 2002/2003 Discussions about the Visual Studio.NET programming environment, the 2002 (1.0) and 2003 (1.1). ** Please don't post code questions here ** For issues specific to a particular language in .NET, please see the other forum categories.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VS.NET 2002/2003 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old August 13th, 2004, 12:47 AM
Registered User
 
Join Date: Aug 2004
Location: Trivandrum, Kerala, India.
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default Difference between two dates in Vb.net

Hai,
 I have a problem with the difference between two dates.
I need the out put in month.days
ie. for eg:
     2.5 months
With dateDiff function it is not possible.
Can u help me..

Thanking u

regards,

Bimal
Reply With Quote
  #2 (permalink)  
Old August 13th, 2004, 09:47 AM
Friend of Wrox
Points: 3,489, Level: 24
Points: 3,489, Level: 24 Points: 3,489, Level: 24 Points: 3,489, Level: 24
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Central, NJ, USA.
Posts: 1,102
Thanks: 0
Thanked 2 Times in 2 Posts
Default

Why isn't it possible?

Hal Levy
Web Developer, PDI Inc.

NOT a Wiley/Wrox Employee
Reply With Quote
  #3 (permalink)  
Old August 13th, 2004, 03:49 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , .
Posts: 540
Thanks: 0
Thanked 4 Times in 4 Posts
Default

As far as I know, the DateDiff function always rounds down to the closest month so 15 weeks would be the same as 16 weeks in terms of months.

Would something like:
--------------------------------------------------------
Dim MonthsDiff as Double

MonthsDiff = FormatNumber(((DateDiff(DateInterval.Day, Date1, date2) / 7) / 4.33), 2)
--------------------------------------------------------

work for you?

J
Reply With Quote
  #4 (permalink)  
Old August 15th, 2004, 12:23 PM
Registered User
 
Join Date: Aug 2004
Location: Trivandrum, Kerala, India.
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hai Levy,

Thanks for your reply.
But the problem is still their.
Your solution only give approximate result.
ie. for eg:
Diff b/w 1/1/2003 and 31/12/2003 will give
     result as ==> 12.04 that means 12 months 4 days.
Here actual value is 12 months 0 days
Check it..

Is their any accurate methods.

Hoping to here soon...
Thank you

regards

Bimal
Reply With Quote
  #5 (permalink)  
Old August 15th, 2004, 09:49 PM
Authorized User
 
Join Date: May 2004
Location: , , .
Posts: 46
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I never know that there is a method to check date differences. but if I were you, I would do it manually.

Reply With Quote
  #6 (permalink)  
Old August 15th, 2004, 11:32 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , .
Posts: 540
Thanks: 0
Thanked 4 Times in 4 Posts
Default

Actually, that was me that replied, not Hal.

I know it won't be exact but it wasn't supposed to be. Every month has a different number of days to it (28, 30, 31) plus you have to account for leap years, so you will likely have to write a function that does a little more work than this. I thought all you wanted was an estimation of the total months - in your first example (2.5) months or roughly 2 1/2 months.

J
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
substracting dates in vb.net Yasho VB.NET 2002/2003 Basics 1 May 23rd, 2007 12:37 AM
How to handle dates in VB.net Yasho VB.NET 2002/2003 Basics 3 May 16th, 2007 02:41 PM
Functional Difference Between VB .net And C# Amitchoudhary .NET Framework 2.0 7 September 15th, 2006 08:06 AM
Difference in Dates mcinar Javascript How-To 0 May 8th, 2005 07:08 PM
Difference between VB6.0 and VB.Net-illustrational ramk_1978 General .NET 1 December 31st, 2004 01:57 PM



All times are GMT -4. The time now is 02:47 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.