Jump to content
Xtreme .Net Talk

How to Calculate Years & Months & Days ?


Recommended Posts

Posted

hi all

 

I am trying to calculate Date.Now from start Time

 

by using DateDiff ... here's the code

 


Try
     Dim d1 As DateTime = CDate(DTPStartDate.Text)
     Dim WD As Long = _
     DateDiff("yyyymd", d1, Date.Now)
           
      txtTotalDays.Text = WD

    Catch ex As Exception
    MessageBox.Show(ex.Message)
       End Try

 

 

I want the output like 3,5,12

 

means 3 years , 5 months , 12 days

 

I used what ever I can to format the Interval with no result.

 

how can I get this, is it by DateDiff ?

 

any help would be appreciated

Gary Says: To be a good programmer, you must be good at debugging

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...