How to format a SharePoint ListItemProperty Date Field - sharepoint

I've got a SharePoint (2010) list with a date field on it.
Now in my custom display form I can go ahead and add the field
<SharePoint:ListItemProperty Property="MyDateField" runat="server" id="ListItemProperty1" />
which results in the following output
21.02.2011 15:44
How can I tell SharePoint to format the Date to
21.02.2011
The only way so far seems to be to create a new calculated column based on that date field and do the formatting within the field definition, but that kind of seems to be the wrong way.
Any help would be much appreciated.

When you create the "Date" column in the list, there is option to select: 1)Date only ; 2)Date and time.
If you select the first option, then in the display form, only the date is shown

I had a similar task to perform recently, but the client wanted the time stored as well as date, just not to display the date.
The way I got around this was to create a Calculated Column which displayed the date in the format required, and I then just pointed my field control to display that column.
The calculated column had this formula:
=TEXT([News Article Date],"dd MMMM yyyy")
FYI: this was in a page layout.

Please see http://panvega.wordpress.com/2008/12/08/ddwrtformatdate-with-different-formatflags/ for custom pages.

programmatically (powershell):
$web = get-spweb http://thingy/
$list = $web.lists["List Name"]
$datefield = $list.fields["Date Field"]
$datefield.displayformat = [microsoft.sharepoint.spdatetimefieldformattype]::dateonly
$datefield.update()

Related

Netsuite workflow condition pulling on date field was edited

I am trying to set a condition in a NetSuite workflow so it only triggers when the date of emp. Termination = today and the date that same field was edited also = today. This is what I have but it is not working:
(DECODE({systemnotes.field.id}, 'custentity_emp_termination_date',{systemnotes.date})={today}) and {custentity_emp_termination_date} = {today}
Thanks in advance!
{systemnotes.field.id} is not a real field. It implies a multi-level join (from current record to System note to Field), which NetSuite does not allow outside of SuiteAnalytics. The "Name of Field" can be viewed if you put "{systemnotes.field}" in a saved search to see how it is formatted since it'll have to be exact.
Replace the code with:
DECODE({systemnotes.field}, 'NAME OF THE FIELD',{systemnotes.date})

Sharepoint Date and difference

In my list i have created calculated field to get the difference between the last modified date and today's date.
I use the formula
=datedif([modified],[today],"d")
It is throwing an error : The formula contains reference(s) to field(s).
Please advise.
I do not have a separate column to hold today's date.
Regretfully, you cannot use [Today] for calculated fields. Calculated fields only update when an item is modified, so the Today Trick of creating a column named Today, setting your calculated field, then deleting that column, is a bad move.
You have a couple options, the best of which is probably to use JavaScript within a Content Editor Web Part on the page to do the calculation for you. You could also try using SharePoint designer and custom XPath and xslt to get "days since modified" to appear on your page.
Generally, if you want something to identify items that haven't been modified in a while, it should be done with filter library views: they can use [Today], and they don't require tricks or workarounds.

How to get the Current Date & Time Automatically to a Date Time Field

I have created a date time field I made today's date as the default value, Then I added it to a page layout and created a page, But the current Date Time is not picking up from the system.
I dont want to give the user to select a Date Time instead it should populated automatically
Is there anyway to achieve this without writing code in code behind files?
This is very similar to this question I think
SO - How to get Date and current time from the Date/Time column in SharePoint Custom list
My answer there gives a few options such as using the built in Created field, using a calendar template, a JavaScript hack and a custom field type.
Guys, fake [Today] trick worked for us - but prob is we only got the date value not datetime.
Janis, is it possible to get date and time both from the fake [today] column trick? pls refer few articles on the same
Does [Today] work?
If you have language pack applied to SharePoint, then you must use localized "Today" string.

SharePoint Document Library Customization for document view

I have a document library in MOSS 2007 which has folders and files. Document View in the document library has the following columns: document name, type, Created datetime, created by,modified datetime. How to configure the view so that it doesn't show any information for "modified", "created" and "created by" fields for folders. In other words,I want those fields to be empty for "folder" content types in document library document listing. Thanks in advance.
[Edit] Although, Paul-Jan's answer partially addresses my question, I still don't how to solve the columns "Created By" & "Modified By". There's no attribute to refer them in "Calculated Value". Kusek said "Editor" can be used to address the "Modified By" attribute of a document but that is not working
You can use calculated columns to do this. For each column you want to have, create a calculated alternative, testing whether the content type is or isn't "folder". For example, you'd create a column ModifiedNoFolder, defined as
=IF([Content Type]<>"Folder",[Modified],"")
Make sure to assign the right type to the calculate column (datetime). Now remove the original Modified column from the view and add ModifiedNoFolder in stead.
Oh, and if you meant "in code" (making this question more programming-related), you could do the above in code. :-)
You could add javascript to the master page or the view's aspx page that will search the DOM for the relevant sections and hide them.
modified by = #Editor is in the form of html value.
The suggested calculated column w/ formula: =IF([Content Type]<>"Folder",[Modified],"") will not work for documents being added to a library. Apparently this column is set before the modified date is set, so when upload the doc, the calculated column value will be set to "12/30/1899 12:00 AM" and the modified value will have the correct date/time

Sharepoint, Create View, Filter Properties

I'd like to create a view in Sharepoint that has a filter based on a date field.
The filter should be >= Today and <- Today + 90 days.
I found a reference to the
<Today OffsetDays=”5” />
CAML function and could probably use this by setting the view using the API.
My question is how do i set this using the browser based admin page?
alt text http://www.isuppli.com/Img/Development/CreateViewSample.gif
This can be done OTB using the filter dropdowns when modifying or creating a view:
Filter Image
alt text http://img91.imageshack.us/my.php?image=filterew5.png
Edit: Fixed image
Ok... when you using formula for the column...
It cant using [Today] because it doesnt exsist on the list column...]
So i suggest that you must required the column Today first, so you can use [Today] At the formula..
i think u just dont have using CAML or column formula, but it can do from filtering like AdamBT says...
Hehehe...

Resources