Reputation: 495
I'm trying to populate a gridview with, among other things, a date field using a LINQ query that pulls data from an Oracle database. My problem is the date format that winds up displaying in the gridview is: MM/DD/YYYY HH:MM:SS
. I only want to show MM/DD/YYYY
. What change do I need to make to my query to achieve this?
Dim InfoDetails =
From Lines In dtMain _
Where Lines.Field(Of String)("ULTIMATE_PARENT_NAME") = lstUPs.SelectedItem.ToString _
And Lines.Field(Of String)("CHANGE_TYPE") = Chng_Type.ToString _
And Not Lines.Field(Of String)("WARNING_TYPE").StartsWith("WARNING: DATA L") _
Group By Change_Title = Lines.Field(Of String)("TITLE"), _
Change_Details = Lines.Field(Of String)("DESCRIPTION"), _
Effective_Date = Lines.Field(Of Date)("EFFECTIVE_DATE"), _
Change_Type = Lines.Field(Of String)("CHANGE_TYPE") _
Into Fieldname = Group, Count()
Upvotes: 1
Views: 1526
Reputation: 152491
You can either specify the format in the grid (recommended) or change the output type to a string:
Effective_Date = Lines.Field(Of Date)("EFFECTIVE_DATE").ToString("MM/dd/yyyy"), _
I would strongly recommend setting the format in the grid, but since you didn't specify anything about the UI I can't give any specific advice.
Some drawbacks of converting to string are:
Upvotes: 3