in

SharePoint Blogs

The Best Place for SharePoint-related Blogs

This Blog

Syndication

News

Interested in consulting work or becoming a consultant? Contact Me.

- Quick Links -


- Blog Bits -
 My Professional Profile




Subscribe in NewsGator Online
Add to My MSN
Add to Google

Subscribe with Bloglines





Tags:

Translate Text or URLs
Who links to my website?

The Boiler Room - Mark Kruger (5 Year Microsoft SharePoint MVP)

Using [Today] in a Calculated Formula (Birthday Lists)

 

Using [Today] in a Calculated Formula (Birthday Lists)

 

Ok, we all know that SharePoint loves to complain about how you can't use [Today] in a calculated column…

 

"TODAY - Returns the serial number of the current date. The serial

number is the date-time code used for date and time

calculations.

Note  You can only use the TODAY function as a default

value; you cannot use it in a calculated column.")

 

Well, I can't take credit for this one but I found this thread in the forums by a gentleman named Pete Blair... I also was watching a thread at SharePointU so I thought it was worthy of a Blog post to answer once and for all! ;)

It is possible to use "Today" in a function as a reference to today’s date

(despite what SharePoint tells you).  There is a very simple work around that

doesn't involve very much effort or complexity.

 

  1. First, create a new column in your list with the column name of "Today".  
    Click "OK".  (It doesn't matter what type of column or data it is, this is
    just a place holder and will be removed later).
    MK Note: Create column called Today... I also created a column called DOB (date field) where I will enter the birth date.
  2. Next, create a column with the data where you would like to use "Today" as a
    reference to today’s date.  The column type should be "Calculated".  In the
    formula field, create your formula using "Today" as if it held the column date/time.
    SharePoint will calculate the formula based on the assumption that you will
    be using "Today" as a reference to the new column you just created.
    MK Note: I created a column called MonthCheck with the formula shown below:
     =IF(MONTH([Today])=MONTH([DOB]),"Birthday","NotBirthday")
  3. Next, edit the new column named "Today" that you created in the first step.  
    On the very bottom of the page,
    click "Delete", to delete the column.  In
    your formula, SharePoint will keep the reference to "Today" but it will
    change from referencing your column, to a reference to the current date.
  4. MK Note: Now you can create your new view in the list to display “This Month's Birthdays“.  Just apply a filter to Show only when the following is true: MonthCheck is equal to Birthday
    I've also created a BirthDay Column (Capitalized the “D“ to note the difference) as well that is a calculated column: =DATE(YEAR(Today),MONTH(DOB),DAY(DOB))
    You can then create a view to display Today's Birthdays by filtering to Show only when the following is true:
    BirthDay is equal to [Today]

 

This can be used in any of the Date and Time functions, but I haven't tested

it beyond that.

 

Notes:

If you want to edit the formula (CheckMonth) containing "Today" SharePoint will not let

you, and will give you the same error about not using Today or Me in a

function.  To get passed this problem you have to temporarily create another

Today column (and then delete it again).

The same functionality will also work with [Me].

 

Ted Tang has a great post on using “< MONTH />” by making modifications within FrontPage:How to ONLY Display "This Month" Items in a List

Comments

 

Links (6/26/2007) « Steve’s SharePoint Stuff said:

Pingback from  Links (6/26/2007) &laquo; Steve&#8217;s SharePoint Stuff

June 26, 2007 8:59 PM
 

Vadim said:

It works, but next day (or month) you see that nothing has changed in your lists. It seems that Sharepoint remembers current value of [Today] at the moment you create (and delete) columns, and your filters stay the same. If you repeat the procedure next day, it will be OK again.

Any ideas/comments?

July 17, 2007 11:42 PM
 

Ange said:

I have the same problem -- I need the list to automatically reflect the current month, not the month that was stored in the field [Today]

July 25, 2007 11:56
 

MindBusiness Blog » Verwenden von [Heute] in berechneten Spalten said:

Pingback from  MindBusiness Blog &raquo; Verwenden von [Heute] in berechneten Spalten

August 15, 2007 11:55 PM
 

Ryan McIntyre said:

Scenario: A list contains items which have a recurring date. Anniversary, birthday, things like that.

August 17, 2007 4:33 PM
 

Mohiuddin Qadri said:

What about current time? Today is returning today's month date and year. It doesn't return current time.

How is it possible to calculate based on current time??

September 4, 2007 3:32
 

Joel said:

Argh! I swear something similar this worked in SharePoint 2003 (like joelsef.blogspot.com/.../recently-updated-documents-in.html). But this birthday trick doesn't work month-to-month--when the month changes over the calculated column still keeps the [Today] value of the month when the calculated column was created.

September 5, 2007 10:07
 

how to get a copy of high school diploma in texas said:

how to get a copy of high school diploma in texas

September 8, 2007 3:15
 

government graduate student grants said:

government graduate student grants

September 11, 2007 5:42 PM
 

Murky said:

This trick doesn't seem to work for the same reasons others mention here. I wanted to use "today' in an if statement, but it wasn't working so I changed the calculated field to simply display today's date "=today". When I first created the field it displayed today's date. But the next day when I looked at the field it was still displaying yesterday's date instead of changing to today's date. That makes this trick useless. Am I doing something wrong?

November 1, 2007 3:40 PM
 

Seajoker said:

I have a recurring task that is set for the first day of the month.  How can I apply a calculation on a recurring date?  I want to add or subtracts days based on the recurring date.  My current problem is the recurring date calculation, calculates based on the first day of the entry and not the next month's date.  Any work around?

November 7, 2007 1:54 PM
 

Alessandro said:

Well, I did make only a filter with a expression [today],  and I don´t use the formula.

Work IT!! So, only created two box, a with name of person and other with birthday in current year.

Next year, I have remake new birthday in the box.

November 14, 2007 7:36
 

Sheila said:

We need the list to automatically reflect the current date. Any progress on a date function that actually reflects the current date, not just the date that an item was entered? We need to track aging items so that each day, the aged item shows to be one day older than yesterday. Thanks!

November 28, 2007 1:08 PM
 

Loren said:

So I'm almost there. For a birthday list, I took calendar items and assigned the category "birthday." Since the birthdays are recurring, when I show birthdays for the current month using your method, I get them for December of this year and also December of the next two years. Best way to effectively show only this year's info?

December 4, 2007 4:03 PM
 

FL said:

You must go to Texas

January 7, 2008 12:59 PM
 

Tarek El-mallah said:

this is wrong method , this wll work only when save the item, but if the today date changes it will not change automatic untill you edit item then save it again

January 13, 2008 3:32
 

krishna kant dubey said:

This method can be used to show created date not current date.

January 14, 2008 5:11
 

Mark Kruger (SharePoint MVP) said:

Folks, this method was used within 2003 and was a quick way to generate birthdays for the month.  It is not an automated solution and has not been tested in MOSS 2007.

January 14, 2008 8:02
 

Using [Today] and [Me] in SharePoint calculated columns « onlydarksets said:

Pingback from  Using [Today] and [Me] in SharePoint calculated columns &laquo; onlydarksets

March 20, 2008 3:33 PM
 

Eric said:

If you want to capture the value of the volitale function [Today] in a calculated column then why not just use the value in the "created" column?  I don't guess I understand the purpose of this workaround.  

In WSS 3.0 it is the default value that has limited functionality because you can't capture the value of another field.  The "created" column should have the same date/time as [Today] though.

March 27, 2008 2:03 PM
 

Vittal said:

this post was very helpful...I have beed in desperate need of something like this...Thanks a bunch

April 16, 2008 3:07
 

Dan said:

I figured out how to do this in MOSS on a list with recurring events:

- Create a text column called 'Today'

- Create a calculated column called 'Birthday' with a formula of =[Start Time], data type = Date and Time

- Create a calculated column called 'bMonth' with a forumula of =MONTH(Birthday), data type = Number

- Create a calculated column called 'tMonth' with a forumula of =MONTH(Today), data type = Number

- Create a calculated column called 'Display' with a forumula of =IF(bMonth=tMonth,"Ok","Not Ok"), data type = Single line of text

- Create a view called 'This Month', select columns to display, sort on Birthday, filter Display, is equal to, Ok

I had an entry in this list from last year (when I gave up on this the first time) for a birthday on 5/6/2007 and it showed up since today is May 1st.

May 1, 2008 11:26
 

Dan said:

Oops... remember to delete the "Today" column before you enter any data.

May 1, 2008 11:28
 

Gristy said:

thanks dan gonna set this up now and find out if it works june 1st :)

May 21, 2008 10:17 PM
 

Motorboy said:

Hi,

I have any problems with there used calculated formulas. When I tried to create this calculated columns ("MonthCheck" and "MonthCheck is equal to Birthday") it retrieved me this error:

The formula contains a syntax error or is not supported.   at Microsoft.SharePoint.Library.SPRequestInternalClass.AddField(String bstrUrl, String bstrListName, String bstrSchemaXml, Int32 grfAdd)

  at Microsoft.SharePoint.Library.SPRequest.AddField(String bstrUrl, String bstrListName, String bstrSchemaXml, Int32 grfAdd)

I don't know why? Any Ideas?

Thanks

May 31, 2008 9:14
 

Gristy said:

well tried what Dan said exactly, and the month didnt change now its june. oh well

May 31, 2008 7:17 PM
 

Gristy said:

well tried what Dan said exactly, and the month didnt change now its june. oh well

May 31, 2008 7:17 PM
 

Motorboy said:

Yes, I have already tried what Dan wrote's, but no progress:-( -> "Syntax Error"...

Simplier formulas like "=DAY(DOB)" or "=MONTH(DOB)" are OK?!

Haven't I vergot set up any settings in CA or in SSP?

June 2, 2008 1:30
 

Kathy said:

Has anyone figured out how to use the TODAY as the current date and time so that items that are tracked for aging are updated?

June 6, 2008 9:01
 

Michelle said:

I am using this to determine someone's age based on subtracting the year in the birthday field from the year in the today field.  This works fine, but i want it to display "n/a" in the age column if the birthday field is null.  Does someone know how to do this?  Here is my current formula for age:

=(YEAR(today))-(YEAR([Child 1 Birthday]))

June 9, 2008 2:07 PM
 

Steven said:

Excellent find!!  Why wouldn't Microsoft include the [Today] functionality as built-in?!?

June 10, 2008 9:31
 

Motorboy said:

I have created similar issue as Michelle.

Two collumns:

DayToday: =DAY(BirthDate)-DAY(Today)

ThisMonth: =MONTH(BirthDate)-MONTH(Today)

where I setted up filter on DayToday=0 and ThisMonth=0, but I found out, that this columns doesn'n re-count automatically :-(

Any Ideas?

June 11, 2008 2:38
 

Nimi Kaul said:

THanks. THis was very helpful.

But, will i have to create the today column every month (everytime a month changes)?

June 17, 2008 6:47
 

Shai said:

Genius.

July 3, 2008 9:38

Leave a Comment

(required )  
(optional )
(required )  
Add

Need SharePoint Training? Attend a SharePoint Bootcamp!

Posts (c) their respective authors. Everything else (c) 2007 SharePoint Experts