2.12.2009

Calculated Default Date with Time

The built in Date Time Column type for SharePoint 2007 lists has a problem that I was surprised to find out about.

When you create a new Date Time column, you are given the option to set the default value to Today's Date. This works fine if all you care about is the date, but if you want the time to default to the current time ... Every time you create a new list item, the time for that column will always be defaulted to 12:00 AM.

To insert a default date and time, use the TIME function in the "Default value:" "Calculated Value:" field:

To insert today's date with a 9:00 AM time:

"=Today+TIME(9,0,0)"

TIME (HOUR, MINUTE, SECOND)

Usually, I have a task list, and I have people from all over the company entering items for me to do. In order to get to them in a timely fashion, I want the default 'Start Date' to be three days in the future, at the beginning of the day so that I can look over the request and prioritize it as I see fit:

"=3+(Today+TIME(8,0,0))"

In addition, I want to default the due date to 90 days from now, at 6:00 PM (basically, End Of Day):

"=90+(Today+TIME(18,0,0))"

The TIME function is on 24-hour (or military) time. Just add 12 to all PM times, and it's pretty easy to figure out. 0,0,0 is Midnight.

This is very useful with the task-type list, because if the due date is 'today', then your task is already overdue because 'today' means 'this morning at 12:00AM!' which has already passed!

1 comment: