list 如何从 SharePoint 自定义列表的日期/时间列中获取日期和当前时间
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2731079/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to get Date and current time from the Date/Time column in SharePoint Custom list
提问by Kanta
I have column called "Date Submitted" as Date/time in one of the Custom list in sharepoint 2007. it always set to today's date and 12AM time instead of that I want to display today's date with current time hh:mm:ss.
我在 sharepoint 2007 的自定义列表之一中有名为“提交日期”的列作为日期/时间。它总是设置为今天的日期和上午 12 点时间,而不是我想用当前时间 hh:mm:ss 显示今天的日期。
I tried creating calculated column TestDate and formula is : =TEXT(([Date Submitted]),"mm dd yyyy h:MM:SS")
我尝试创建计算列 TestDate 和公式是: =TEXT(([Date Submitted]),"mm dd yyyy h:MM:SS")
result is 04 28 2010 0:00:00 I wanted to be 04/28/2010 10:50:34
结果是 04 28 2010 0:00:00 我想成为 04/28/2010 10:50:34
Is it possible to achive this?
有可能实现这一目标吗?
Thank you kanta
谢谢坎塔
回答by jps
try to put =NOW() in the default value field in the column properties
尝试将 =NOW() 放在列属性的默认值字段中
回答by Rich Bennema
In the definition of Date Submitted, is the Date and Time Format currently Date Only? If so, try changing it to Date & Time.
在Date Submitted 的定义中,Date and Time Format 当前是否为Date Only?如果是这样,请尝试将其更改为日期和时间。
回答by Daniel Dolz
For something like this, I ended up creating a custom action which is called from a workflow.
对于这样的事情,我最终创建了一个从工作流调用的自定义操作。
回答by Ryan
A few ideas to get you started :-
一些帮助您入门的想法:-
Can you use the Created date instead - it will always be set to the exact time the record was created?
When entering a new item on the Calendar list it defaults to the current time - could you make your list from a modified Calendar list rather than the Custom list?
I've written a blog post about how you can use a JavaScript hack to set the default duration for a new calendar record - you could modify this to use with a Custom list and to set the field to the current time.
You could write your own custom field type
SharePoint 2007 Custom Date Time Field to default the time to the current time
您可以改用创建日期吗 - 它将始终设置为创建记录的确切时间?
当在日历列表中输入一个新项目时,它默认为当前时间 - 您可以从修改后的日历列表而不是自定义列表中创建列表吗?
我写了一篇关于如何使用 JavaScript hack 设置新日历记录的默认持续时间的博客文章 - 您可以修改它以与自定义列表一起使用并将字段设置为当前时间。
您可以编写自己的自定义字段类型
回答by Bobby
=TEXT([DateFiled Here],"mm/dd/YYYY hh:mm:ss ")
=TEXT([DateFiled Here],"mm/dd/YYYY hh:mm:ss")
回答by urbanaut
Here's how to do what you want:
以下是如何做你想做的事:
=TEXT(Today,"mm/dd/YYYY")&" "&TEXT(Now(),"h:mm:ss")