Saturday, March 24, 2012

Text to date conversion

Hi all,

I have a text box I can restrict the user to enter the date in dd-mm-yy hh:mm:ss am/pm

but after taking that How can I make sure that it is a valid date and(date validations) and it should be <=currentdate.

I am inserting it in the oracle data base there it should be in 17-Dec-2003 12:00:01 AM this format.

I know that I can write a function but I am no wise in it could any one please help me out in this. I am really stuck with it

formating date, see sample: http://apriendavisualstudio.net/c/format-datetime-c/


//string strDate="2002-10-03";

//string strDate="10/04/2002";

string strDate="10/05";

DateTime dt = (DateTime)(TypeDescriptor.GetConverter(new DateTime(1990,5,6)).ConvertFrom(strDate));

Response.Write(" " + dt.DayOfWeek);


Look at the AJAX Control tool kit masked edit control

http://www.asp.net/AJAX/AjaxControlToolkit/Samples/MaskedEdit/MaskedEdit.aspx

this ensures your input matches the format you require

0 comments:

Post a Comment