0

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..

Bhargav
  • 124
  • 6
  • 19
  • How are you binding the grid, which control are you using to bind? If you are using gridview you can refer this post. http://stackoverflow.com/questions/4033113/how-to-format-datetime-columns-in-datagridview – Kiran Hegde Jul 01 '14 at 06:32
  • Thank you Kiran for your quick response and help. Yes I am using a gridview and this link served my purpose like a charm. Thanks again... :) – Bhargav Jul 01 '14 at 10:56

1 Answers1

1

You can get Only Date from DateTime field of SharePoint with following code:

string date = Convert.ToDateTime(item["DateColumn1"].ToString()).ToShortDateString()
Ronak Patel
  • 295
  • 3
  • 11
  • Thanks For the response Ronak..! Marking it as answer as this would help someone looking for the answer in future. – Bhargav May 18 '16 at 10:15