Parameter’s passage

Asked

Viewed 35 times

1

I have the following code that dates the Mysql database to textblock:

 textBlock8.Text = (reader.GetString("Data"));

What happens is that it is passing the date and time. I would like to pass only the date.

  • You’re getting a date text, right? The date format is guaranteed to always be the same? What would it be?

  • If you do GetString("Data").ToString("dd-MM-yyyy") doesn’t work?

1 answer

1


You can use the class Convert, to convert to date

textBlock8.Text = Convert.ToDateTime(reader.GetString("Data")).ToString("dd/MM/yyyy")

or use the DateTime to give a Parse in string

textBlock8.Text = DateTime.Parse(reader.GetString("Data")).ToString("dd/MM/yyyy")

Browser other questions tagged

You are not signed in. Login or sign up in order to post.