简体   繁体   English

如何从Sharepoint 2013的DateTime字段中获取唯一日期?

[英]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. 我正在尝试从包含DateTime列的共享列表中获取数据。 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 . 当我将此列表数据绑定到网格时,此DateTime列的绑定字段以以下格式提供值: 7/1/2014 12:00:00 AM I have put the DateTime Column as " Date only " but still getting the same. 我已经将DateTime列设置为“ Only date ”,但仍然保持不变。 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()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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