Click here to Skip to main content
15,913,027 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Actually i am using one text box to enter date. my problem is some one is typing dd-mm-yyyy (or) mm-dd-yyyy (or) dd/mm/yyyy like this any format they type in textbox but i should save in table can i Achieve this.....

Mote:-for that text box i taken ajax calender to select date(Here my problem is if they not selected from the calender if they entered means how should i convert into date if it is in date format means)
Posted

Hi, try to use this:

Example

C#
string inputDate = "03/12/2012";

DateTime dt = DateTime.MinValue;
dt = DateTime.Parse(inputDate);

string formatDate = String.Format("{0:MMM d, yyyy}", dt); //Set on how the format of ajax calendar has been set



Hope it helps! :)
 
Share this answer
 
C#
1) DateTime.Parse("your date", System.Globalization.CultureInfo.InvariantCulture);

2) DateTime.ParseExact("your date", "dd-MMM-yyyy",System.Globalization.CultureInfo.InvariantCulture);
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900