loyal Posted November 28, 2003 Posted November 28, 2003 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 Quote Gary Says: To be a good programmer, you must be good at debugging
*Experts* Volte Posted November 28, 2003 *Experts* Posted November 28, 2003 You should look at the TimeSpan class, which returns the difference in the standard DateTime format. Quote
bungpeng Posted November 29, 2003 Posted November 29, 2003 DateDiff just return you total days, you can divide it to get the ? years, ? months and ? days if you want... DateDiff("d", d1, Date.Now) Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.