user1702595 user1702595 - 4 months ago 18
Vb.net Question

How do I convert 01 January 2002 into a VB.NET Date Format

How do I convert 01 January 2002 into a VB.NET Date Format

I work out the days from that date until today in VB.net

Thanks

Answer

Date.Parse is used to Parse a string to a date.

Then take this away from DateTime.Now to find the number of days:

MessageBox.Show((DateTime.Now - Date.Parse("01 January 2002")).TotalDays.ToString())

No need for DateTime.ParseExact here because that date cannot be ambiguous