Computing.Net > Forums > Programming > Help with Date in VB.net

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Help with Date in VB.net

Reply to Message Icon

Name: vbhelpneeded
Date: April 29, 2006 at 10:52:50 Pacific
OS: xp
CPU/Ram: 2000/512
Comment:

Hi,

Im writing a program, and as part of it i need to calculate how many days have passed since a certain date.

I am able to get the date from a database and pass it into vb.net, however am unable to calculate how many days/months since todays date.

anyone know how to do this? any help is greatly appreciated!




Sponsored Link
Ads by Google

Response Number 1
Name: SN
Date: April 29, 2006 at 15:31:51 Pacific
Reply:

No problemo...Just do a date subtraction, which returns a TimeSpan class, which then has a "Days" property.

Dim d as DateTime = new DateTime(2006, 04, 28);
DateTime.Today.Subtract(d).Days 'returns 1 on 4/29/06.

DateTime documentation

Good luck,
-SN


0
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Help with Date in VB.net

Printer paper collection in VB.NET www.computing.net/answers/programming/printer-paper-collection-in-vbnet/11265.html

Adding tabs in a string in vb.net www.computing.net/answers/programming/adding-tabs-in-a-string-in-vbnet/11853.html

rinning .reg in vb.net www.computing.net/answers/programming/rinning-reg-in-vbnet/13813.html