how to convert string value to datetime accoring to current culture
-
i have two string values "MM/dd/yyyy" & "dd/MM/yyyy" when i assign to sql parameters if the culture accepts MM/dd/yyyy then it gives error on dd/MM/yyyy cannot convert string to datetime. is there any way to convert string to datetime according to current culure i have tried textbox.text.tostring(system.threading.thread.currentthread.currentculutre) but no use datetime.parse(string) not do anything.... and i cannot use convert.todatetime function because these dates may b empty.
umerumerumer
-
i have two string values "MM/dd/yyyy" & "dd/MM/yyyy" when i assign to sql parameters if the culture accepts MM/dd/yyyy then it gives error on dd/MM/yyyy cannot convert string to datetime. is there any way to convert string to datetime according to current culure i have tried textbox.text.tostring(system.threading.thread.currentthread.currentculutre) but no use datetime.parse(string) not do anything.... and i cannot use convert.todatetime function because these dates may b empty.
umerumerumer
you have to change the format of string using following way.this is for binding the date with textbox.in your case you have to pass the date in following way to your sql parameter. eg. ]]> Regards, Keyur Satyadev
-
you have to change the format of string using following way.this is for binding the date with textbox.in your case you have to pass the date in following way to your sql parameter. eg. ]]> Regards, Keyur Satyadev
but i want to do it after picking it from the textbox is there any way to convert string accoring to current system date time format
umerumerumer
-
but i want to do it after picking it from the textbox is there any way to convert string accoring to current system date time format
umerumerumer
actually right now i am facing problem like DateTime.Today.Date.ToString(System.Threading.Thread.CurrentThread.CurrentCulture.DateTimeFormat.ShortDatePattern) it is not picking my system datetime format :( always use MM/dd/yyyy even i am using dd/MM/yyyy
umerumerumer
-
actually right now i am facing problem like DateTime.Today.Date.ToString(System.Threading.Thread.CurrentThread.CurrentCulture.DateTimeFormat.ShortDatePattern) it is not picking my system datetime format :( always use MM/dd/yyyy even i am using dd/MM/yyyy
umerumerumer
use the following code System.DateTime.Today.ToString("dd/MM/yyyy"); it will be work.