convert a String to a Date

  • Thread starter Thread starter John A Grandy
  • Start date Start date
J

John A Grandy

what's the preferred method in vb.net to convert a String to a Date .... ?
 
CType(string, date)

datevar = CDate(string) is shorter. You can also use Date.Parse or Date.ParseExact which can be used to parse a string in a specific format.
 
* "John A Grandy said:
what's the preferred method in vb.net to convert a String to a Date .... ?

'DateTime.ParseExact'/'DateTime.Parse'.
 
CDate is a holdover from VB 6.0. Many developers like to steer clear of
these functions because they cause more overhead than if the .NET equivalent
class is used.


Eduardo A. Morcillo said:
CType(string, date)

datevar = CDate(string) is shorter. You can also use Date.Parse or
Date.ParseExact which can be used to parse a string in a specific format.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top