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!

How to convert string from text box into DateTime in crystal using C#

Status
Not open for further replies.

salooo

Programmer
Sep 11, 2003
30
US
Hi,
I am using VS.NET, and C#, and in my report I want to allow the user to enter a search crietria for date by typing the date in to 2 text boxes i.e., DateFrom and DateTo.
I want to know how I can convert(format) the text entered into the text boxes to a DateTime, so that I can use it in my selectionFormula. I would really appreciate a brief code example if possible.
Thanks.
Salmaan.
 
It should be as straight forward as the following :

DateTime dt1 = DateTime.Parse(textBox1.Text);

But you might want to invest in a try ... catch around this syntax to ensure that a valid datetime is entered.

Hope that this helps.
Steve
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top