Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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?

share|improve this question
add comment

3 Answers

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)

share|improve this answer
add comment

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!

share|improve this answer
add comment

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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