GIDForums  

Go Back   GIDForums > Computer Programming Forums > .NET Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 23-Aug-2008, 20:19
mmunoz mmunoz is offline
New Member
 
Join Date: Aug 2008
Posts: 1
mmunoz is on a distinguished road
Red face

Date Difference / Years and Months Elapsed


Can anyone guide me as to how to display on a text box the number of years and months that have past between today and the date from a calendar datepicker placed on a form from which the user will select the account opening date. I want display on the text box "This account is x years and x months old".

Here is the code that I am using, but of course is incomplete. Please correct it accordingly. Thanks.
VB / Visual Basic Code:
 Dim Inception As Date = DateTimePicker1.Value
        Dim Today As Date = DateTime.Today
        Dim Span As TimeSpan = Today.Subtract(Inception)

        TextBox2.Text = " This account is " & Span.TotalDays.ToString() & " years old"
Last edited by admin : 04-Sep-2008 at 05:41. Reason: Please insert your example VB codes between [VB] and [/VB] tags
  #2  
Old 04-Sep-2008, 05:28
erniegerdie erniegerdie is offline
Junior Member
 
Join Date: Feb 2004
Location: England
Posts: 84
erniegerdie has a spectacular aura abouterniegerdie has a spectacular aura about

Re: Date Difference / Years and Months Elapsed


Can you not use DateDiff in VB.Net?

DateDiff("yyyy", DateTimePicker1.Value, DateTime.Today) for years

Using "m" for months?
 
 

Recent GIDBlogWriting a book by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 20:14.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.