Andrew
Andrew

Reputation: 111

Is it Possible to display only the Date when printing out a DateTime List?

this.reportTextBox.Text += String.Join(Environment.NewLine, notEqualValue);

This Line of code will print out all of the Tuple values within this list. It will be displayed looking something like this:

(02/12/14 00:00:00, hello)

I only wish to display the Date function of my DateTime method. So it should look like:

(02/12/14, hello)

Is this possible?

The initialization of the Tuple can be seen below.

 Tuple<DateTime, string> a = new Tuple<DateTime, string>(data_entryA.Date, tag_a_name);

Upvotes: 1

Views: 263

Answers (1)

Selman Gen&#231;
Selman Gen&#231;

Reputation: 101701

Sure you can format your dates

var values = notEqualValue.Select(x => string.Join(",",x.Item1.ToString("d"),x.Item2));
this.reportTextBox.Text += String.Join(Environment.NewLine, values);

"d" format specifier gives you the date in format 6/15/2009, but it's culture sensitive. So if you have a different culture try using DateTime.ParseExact method with a custom format string.

Upvotes: 1

Related Questions