Hi,
I am connecting to an MS SQL database and requesting a datetime field. When I run the query in SQL Query Analyzer, I get the date back in year-month-day hour:minute:second format. However, when I run the same query from my C# application, I get a string in the format: month/day/year 12hour:minute:second AM/PM.
Is there a way I can force the format of the date field so that I don't have to worry about the local settings of any given computer? I'd prefer the native SQL format displayed by SQL Query Analyzer, so what is converting this into garbage "for me" in C#? Here's a code snippet in case there are any clues there:
Thanks for any insight.
I am connecting to an MS SQL database and requesting a datetime field. When I run the query in SQL Query Analyzer, I get the date back in year-month-day hour:minute:second format. However, when I run the same query from my C# application, I get a string in the format: month/day/year 12hour:minute:second AM/PM.
Is there a way I can force the format of the date field so that I don't have to worry about the local settings of any given computer? I'd prefer the native SQL format displayed by SQL Query Analyzer, so what is converting this into garbage "for me" in C#? Here's a code snippet in case there are any clues there:
Code:
MyTableCommand.CommandText = "select ACCDATE from MYTABLE";
MyTableReader.ExecuteReader();
if(MyTableReader.Read())
MyTextBox.Text = MyTableReader["ACCDATE"].ToString();
Thanks for any insight.