Pages

6/23/2011

SharePoint: Edit date and time in one minute increments

When working with SharePoint date fields you are offered a Date Picker that let’s you select time to the nearest five minutes.

While this works fine for most tasks and meetings, some manufacturing processes need the time set to the minute.

.

I first tried some quick JavaScript tricks to change the dropdown list to include 00 to 59, but it appears that the server side code only expects the dropdown to only have five minute steps and that causes an error on save. The next experiment was to create custom New and Edit forms to allow free form edits. Turns out you don’t have to do anything special to the Display form or the views as they just display whatever was entered.

The steps below generally follow what you will find in other blog sites or this MSDN article, expect for replacing the Date Picker fields with Text Box fields.

Test this on a “test” list before duplicating on a production list!

List Preparation

Before we can enter times, you need to configure your list to support Date and Time. Simply go to the list’s properties and edit the date field to support Date & Time.

Also add a Description to your date fields with a sample of an acceptable date. Remember that the user no longer has a date picker to make sure they select a valid date. Something like: “Enter dates as mm/dd/yyyy hh:mm AM/PM”

Disable Attachments!

The following edits will not work if Attachments are enabled for the list. Go to List Settings, Advanced and disable attachments. I think this error is caused by having two web parts on the same page, each adding some common ID that confuses the page’s JavaScript (I did a search and found this article, http://support.microsoft.com/kb/953271, but I did not try it’s solution.)

This edit will display “A.D.” in the Design view, but will display the correct data in the browser.

Now test and confirm that it now looks like this:

Hours, Minutes and Seconds?

SharePoint will store time to the second. There are no additional changes needed for the NewForm.aspx page, and EditForm.aspx only needs the “g” in the FormatDateTime changed to “G”. The real work will be in also creating a custom DispForm.aspx and custom views.

thanks for your workaround for this issue. I haven't found any other solution so far online that will not affect the column names or data (as would be in the case of creating a new custom field). I can also confirm that Javascript injection in select box does not work when trying to save.

However, is there a way to have the NewForm pre-filled with the current DateTime? The =Now() formula does not seem to work anymore since the conversion to textbox. So, when a user tries to add a new item he sees an empty textbox instead of the current date/time, which is a show-stopper.

I have several calculated columns that I have added to my list since making the conversion from date/time picker to textbox. When I go back to view the New Form or Edit Form in SP Designer, it does not display the form fields any more, which incidentally makes it very difficult to make any further changes. Any ideas on why they won't load?

I have several calculated columns that I have added to my list since making the conversion from date/time picker to textbox. When I go back to view the New Form or Edit Form in SP Designer, it does not display the form fields any more, which incidentally makes it very difficult to make any further changes. Any ideas on why they won't load?