Reputation: 124
I am trying to get data from a sharepoint list which contains a DateTime Column. When I am binding this list data to a grid, the bound field for this DateTime Column is giving values in this format: 7/1/2014 12:00:00 AM. I have put the DateTime Column as "Date only" but still getting the same. This is not the behavior I wish to have...I need only the date to come in my grid. Can someone please kindly suggest how I can achieve this. Any help would be greatly appreciated.
Thank you..
Upvotes: 0
Views: 5315
Reputation: 305
You can get Only Date from DateTime field of SharePoint with following code:
string date = Convert.ToDateTime(item["DateColumn1"].ToString()).ToShortDateString()
Upvotes: 1