“Today”, “Me” and SharePoint

I have already talked about the popular “Today” trick, and explained how you can get the same result by simply using the [Modified] column:
https://pathtosharepoint.wordpress.com/2008/08/14/calculated-columns-the-useless-today-trick/

I have a strange feeling about this. People who have been using this trick for years don’t believe me (which makes me doubt), but at the same time they can’t prove me wrong.

Anyway, let’s move on and review the “Me” trick.

The “Me” trick is similar to the “Today” trick, here are the steps (for details, see the above link):
1/ Create a text column called “Me”
2/ Create your calculated column(s) where you can use [Me] in the formulas
3/ Delete the [Me] column – this is mandatory for the trick to work
4/ If later you need to modify your calculated columns, remember to re-create the [Me] column

Note that:
– the “Me” trick will return the user’s login, not his/her display name.
– like the “Today” trick, the field is only modified when you update the list item. So you should actually understand [Me] as the last user who modified the item.

If so, why not simply use the [Modified by] column? Well, if you try, SharePoint will return an error message:
One or more column references are not allowed, because the columns are defined as a data type that is not supported in formulas.
Columns of type “Person or Group” are not allowed in formulas. So the [Me] trick can help you bypass this limitation. Nevertheless, keep in mind that the “Today” and “Me” tricks are not supported by Microsoft.

How about “Created by”?

If you want to reference in a formula the user who created the list item, you need a different approach. As before, you’ll fail if you try to include [Created By] in your formula.

Instead, create a column of type “Text” – let’s call it “TheAuthor” for example – with as default value: = [Me]. The column will automatically be populated with the user’s login (not the display name), and you can use this column in formulas.

One limitation: the default value is just proposed by SharePoint, users can overwrite the field (unlike the above “Me” trick).

I’ll dedicate a future post to [Today] and [Me] in a more useful context: the filtering of list views.

8 thoughts on ““Today”, “Me” and SharePoint

  1. Hi Christophe,
    I have used your “Text to HTML” with great success and thought maybe i could contribute with my workaround the “Today issue”. Here is my javascript for displaying a status column (green – yellow – red) based on a “Due date column” in the list item and compare it to “Today”.

    Sorry could not paste the sourcecode – it got discarded…
    Can i send it to you Christophe so you can review it and maybe post it?

    Keep up the good work!

    Regards
    Alexander Bautz

  2. Yes Alexander, I got your e-mail.

    I have received a couple scripts from readers, and as promised I’ll publish them. I just need a little time to validate the scripts and maybe add a few comments.

  3. You can use a PowerShell script to update a field in a SharePoint list set at either 5 mins to start of everyday to give you current date and time.

    cls
    Add-PSSnapin Microsoft.SharePoint.Powershell
    $web=get-SPWeb “http://sitename/”
    $web.title
    $list=$web.Lists[“Your List”]
    $list.title
    foreach($item in $list.Items)
    {
    $item[“Duration”] = “$Get-Date”
    $item.update()
    }
    $web.dispose()

    Then set it to run in task scheduler, and make sure you set the field that’s being updated to a date time field and chose whether you want just the date or date and time

    • Thanks for sharing Tom.

      What I don’t like about this approach is that you lose track of the real modified date for the items. Not to mention concerns with versioning or alerts!

Comments are closed.