Ask a questionAsk a question
 

AnswerHow to get current date AND time

  • Tuesday, November 03, 2009 6:04 AMJeremyGB Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    I have a calendar that is used to track who is on-call.  I need to create a filter that will only show the person that is currently on-call.  The Today function will return all the people that are on-call during that particular 24 hour period.  Is there a way to get it to narrow down to just the person who's on-call "right now"?

    Thanks

Answers

  • Thursday, November 05, 2009 1:02 AMJeremyGB Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    Thanks for the ideas.  I have come up with a much simpler workaround to the [Today] function not passing the time to a filter - at least for this application. 

    I created a choice column called status with the choices being "on" and "off".  Then I created a workflow that starts when a new item is created.  The first action is to pause until the start time, then change status to "On", then pause until the end time and change status to "off".  Now I can easily filter my list view to Status is equal to "on".  The workflow pause action uses the the time as well as the date and is fairly close to right on time with the changes - within 30 seconds or so.
    • Marked As Answer byJeremyGB Thursday, November 05, 2009 1:02 AM
    •  

All Replies

  • Tuesday, November 03, 2009 6:28 PMLauraRogers Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    You can do this with a regular list view web part:

    1.  Put a web part of the calendar on your site
    2.  In the web part properties, select the "Current Events" view from the drop-down.  Click OK
    3.  Go back into "modify shared web part" again, and click to "Edit the current view"
    4.  For the selected columns, only select that column with the "person on call".
    5.  Scroll down, and for the item limit, change it to just one item.
    6.  Click OK

    Now you have a web part that only displays the name of the current person on call!

    Laura Rogers, MCSE, MCTS
    SharePoint911
    http://www.sharepoint911.com/blogs/laura
  • Tuesday, November 03, 2009 10:30 PMJeremyGB Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hi Laura,
    Thanks for your reply, but wouldn't this solution only show the first person that is on-call for that whole day? Each day there are at least 3 and sometimes 4 people that take a shift. 
  • Wednesday, November 04, 2009 1:27 AMpl7626 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    I believe you already have a view that will show you the list of people who are on-call today. Open this view in Sharepoint Designer and find the CAML query for this view. Add  IncludeTimeValue=”TRUE” to the attribute of <Value> tag of the query. This will include the timestamp to the view and will show those who are on call at the moment or "right now", whether it's one person or multiple.

    Take a look at Nick's post on this for more details:
    http://nickgrattan.wordpress.com/2008/04/24/filtering-views-by-time-and-date/

  • Thursday, November 05, 2009 1:02 AMJeremyGB Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    Thanks for the ideas.  I have come up with a much simpler workaround to the [Today] function not passing the time to a filter - at least for this application. 

    I created a choice column called status with the choices being "on" and "off".  Then I created a workflow that starts when a new item is created.  The first action is to pause until the start time, then change status to "On", then pause until the end time and change status to "off".  Now I can easily filter my list view to Status is equal to "on".  The workflow pause action uses the the time as well as the date and is fairly close to right on time with the changes - within 30 seconds or so.
    • Marked As Answer byJeremyGB Thursday, November 05, 2009 1:02 AM
    •  
  • Thursday, November 05, 2009 2:03 AMpl7626 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    It's nice to see this working for you. I had tried to use the "Pause Until..." action in a workflow, but it wouldn't trigger the action at the correct time. It appeared to be a known issue.

    You may want to allow the workflow to start when the item is changed or edited. This will take care of any scenarios for schedule changes. But, not sure what effect this will have since the other workflow is already running when the item was created. You may need to experiment with this to see how it behaves.
  • Thursday, November 05, 2009 6:34 AMJeremyGB Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    I had set it to run when modified but it doesn't work. The first instance of the workflow is still running so it just fails.  I'm sure I could just add some more logic to the workflow to get that to work correctly.  For what I am using it for it is easier to just delete the item and create a new one if an adjustment to the date is necessary.