简体   繁体   中英

How to get only date from DateTime Field of Sharepoint 2013?

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

您可以使用以下代码从SharePoint的DateTime字段中获取Only Date

string date = Convert.ToDateTime(item["DateColumn1"].ToString()).ToShortDateString()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM