Jack
Jack

Reputation: 497

DateTime formatting from msaccess to c#

I am probably missing something here. I want to format a DateTime object I retrieve from access (through a tableadapter)into a C# Date object without the time part. Here is my code:

textBox3.Text = table.Rows[1]["DataCreazione"].ToString("MM/dd/yy");

This doesn't work, but if I run the following code I get a System.DateTime response.

textBox3.Text = table.Rows[1]["DataCreazione"].GetType();

Any help would be appreciated!

Upvotes: 0

Views: 36

Answers (1)

sstan
sstan

Reputation: 36473

Looks like you're just missing a cast to DateTime:

textBox3.Text = ((DateTime)table.Rows[1]["DataCreazione"]).ToString("MM/dd/yy");

Upvotes: 4

Related Questions