can i convert string to Date date type...?
Is ther any syntex/command to convert string variable to date variable...
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
SrinivasPosted May 19, 2009, 3:10 AM
This way u can change the data formate and convert to string into data
string UrDate = txtPurchase_Dt.Text;
System.Globalization.DateTimeFormatInfo dateInfo = new System.Globalization.DateTimeFormatInfo();
dateInfo.ShortDatePattern = "dd/MM/yyyy";
DateTime validDate = Convert.ToDateTime(UrDate, dateInfo);
This way you can compate the dates in your application.
DateTime dt1 = new DateTime(2007, 11, 15);
DateTime dt2 = new DateTime(2008, 11, 15);
if (DateTime.Compare(dt1, dt2) < 0)
{
}
else if (DateTime.Compare(dt1, dt2)> 0)
{
}
Please try this solution. I think it will work.
Harish kharviPosted May 19, 2009, 3:25 AM
Harish kharviPosted May 19, 2009, 1:16 AM
Harish kharviPosted May 19, 2009, 1:13 AM
Thank you Sir for your support....
I hope this answer will work....
Tejaswini Prashant JPosted May 19, 2009, 12:54 AM
string strdate = "11/30/2003" ;
DateTime dt = DateTime.Parse(strdate);
or u can also use
DateTime dt = Convert.ToDateTime(strdate);
2nd way
(this works for the given 3 strings dates)
// string strDate="2002-10-03";
// string strDate="10/04/2002";
string strDate="10/05";
DateTime dt = (DateTime)(System.ComponentModel.TypeDescriptor.GetConverter(new DateTime(1990,5,6)).ConvertFrom(strDate));
Hope this will help u out :)
Dnt forget to mark as an answer , if it is :)