Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Converting a string to DateTime

Status
Not open for further replies.

YvonneTsang

Programmer
Sep 28, 2001
37
CA
Is there an easy way to convert a string to the DateTime type? I am retrieving the value from an SQL Database and I want to store it in a DateTime object. What is the easiest way to do this? Thanks in advance.
 
There's two ways:

You can call the Parse method on the DateTime structure, or you can use the Convert class, which has a static method called "ToDateTime" that has many overloads, one of which takes a string. ToDateTime() ends up calling the DateTime.Parse method internally, so use whichever is most convenient for you.

Chip H.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top