5

I'm looking for the best way (if there is one) to show the Modified and Created columns in a list/library with the date only, so without the time. For example, instead of 1/12/2011 8:37 PM it should show 1/12/2011 only. This should not happen on the whole farm/web app/site collection/site, but only for specific lists/libraries.

Things that I thought of so far

  • Adding a calculated column to the specific list/library, that takes the Modifed/Created column's value, and simply reformats to show the date only. Benefit: easy to implement. Drawback: Columns are no longer called Modified/Created. Not reusable, needs to be reimplemented each time
  • create a jQuery solution that hides the time on the client side. Benefit: easily reusable, columns are still named Modifed/Created. Drawback: jQuery code reference needs to be added to each view
  • update the Modified/Created column of the individual list/library to display date only through server-side code. Benefit: Columns are updated properly. Drawback: Not even sure if it's possible to update the formatting? Will the time be lost? Will sorting still work properly?

My preference is #1 at the moment, as it isn't even clear yet how large the scope if this will be (could even be just a few lists/libraries, but might end up with thousands as well).

Are there any other things I need to consider? Anything else that I haven't thought of yet?

4 Answers 4

2

I would also use the calculated column. It's the most easy solution...

Also, if you use jQuery and you migrate to a newer version of sharepoint it could be that your jQuery won't work anymore. (+ you could get a visible change for users with slow computer > since you run this client-side)

1

use the third option:

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

No need to worry about data loss or sorting - the data's still held in a DateTime object, just displayed differently. I actually ran this on my site column instead of the list column, which seems a little bit dangerous because this column is used universally, but nothing has broken yet.

0

If you use a calculated column and you migrate to a newer version of SharePoint, it's more likely that that won't work. (Content Type-Need I say more). Microsoft is less backward compatible than ANY sofware manufacturer BY FAR!

0

You can create a calculated calculate column called ModifiedDateOnly and give it the formula:

=TEXT([Modified],"MM/dd/yyyy").

The C# date text formatters seem to work although I haven't tried them all.

SharePoint Validation TEXT

C# DateTime String Formatters

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.