Your problem is caused by the default culture information. You can define a custom culture and assign it to the current thread. You can do it in the Application_BeginRequest event. The all the request will use the new culture. You can refer to the below
code. You should remember to add the System.Gobalization namespace. The Application_BeginRequest() method is in the Global.asax.cs file.
anilr499
Member
94 Points
389 Posts
date conversion in vb.net.....
Feb 24, 2012 12:13 AM|LINK
i have datofbirth column ....
through a date picker am giving the input...
format(dd/mm/yyyy)
if i give > 12 for dd....
for eg:
if i give 13/4/2012
it is not taking....
it is not accepting the value....
in my database format is yyyy/mm/dd
Can some body help me....
thanks...
Ken Tucker
All-Star
16797 Points
2608 Posts
MVP
Re: date conversion in vb.net.....
Feb 24, 2012 12:16 AM|LINK
it probably wants 13/04/2012
Space Coast .Net User Group
anilr499
Member
94 Points
389 Posts
Re: date conversion in vb.net.....
Feb 24, 2012 12:25 AM|LINK
if igive this also 13/04/2012....
same problem......
Qi Wu - MSFT
Contributor
5794 Points
677 Posts
Re: date conversion in vb.net.....
Mar 01, 2012 09:12 AM|LINK
Hi,
Your problem is caused by the default culture information. You can define a custom culture and assign it to the current thread. You can do it in the Application_BeginRequest event. The all the request will use the new culture. You can refer to the below code. You should remember to add the System.Gobalization namespace. The Application_BeginRequest() method is in the Global.asax.cs file.
protected void Application_BeginRequest(object sender, EventArgs e) { CultureInfo myCulture = System.Threading.Thread.CurrentThread.CurrentCulture.Clone() as CultureInfo; myCulture.DateTimeFormat.ShortDatePattern = "dd/MMM/yyyy"; myCulture.DateTimeFormat.DateSeparator = "/"; System.Threading.Thread.CurrentThread.CurrentCulture = myCulture; }You can’t get your answer with the above code. You need to change it again in the code behind.
DateTime dt = new DateTime(); dt = DateTime.Parse(TextBox1.Text); Response.Write(dt.ToString("dd/MM/yyyy"));If you have any feedback about my replies, please contact msdnmg@microsoft.com
Microsoft One Code Framework