c# - date format in MS access insert is incorrect -
i have problem date format.
my computer's regional setting "mm-dd-yyyy".
i have c# application. , want user enter date in "dd/mm/yyyy" format only.
when user enter 30/10/2010 (means 30th oct 2010) , access not changing anything. ok.
but, if user enters 05/10/2010 (means 05th oct 2010) on lost focus of date text box, automatically changes 10/05/2010. should remain 05/10/2010.
can tell me solution?
plz note, don't want change regional setting.
you have parse input using forced format obtain correct datetime value.
then format neutral string expression concatenate sql statement:
string textdate = "05/10/2017"; iformatprovider provider = system.globalization.cultureinfo.invariantculture; datetime date = datetime.parseexact(textdate, "dd/mm/yyyy",provider); string sql = "... #" + date.tostring("yyyy'/'mm'/'dd") + "# ...";
will return:
date: 2017-10-05 00:00:00 sql : ... #2017/10/05# ...
Comments
Post a Comment