locked
Filter Date & Time Field using hours of the day? RRS feed

  • Question

  • Cannot Filter a field using HH:MM:SS, so what is the correct format to do so?  Every attempt results in "Filter value is not is a supported date format."

    The stupid workaround is to add a Compute field and add the number of hours (as float) to have Date & Time field so it is in a different day (Dumb).

    Thursday, July 23, 2009 11:11 PM

Answers

  • The issue appears to be related the ListViewWebPart Filter only uses the Date.  Although the Field is Date & Time this is only a UI presentation.

    Creating a View programmically and setting Query where clause using '2009-7-24T12:00:00Z', results in all items for 2009-7-24 it ignore the time component.

    Additionally the JavaScript Function 'DOParseLocaleDate' will only accept YYMMDD formatting, but interestingly the value sent to server would:

    function DOStISODate(date)
    {
     var yr=date.getUTCFullYear();
     var mon=date.getUTCMonth()+1;
     var day=date.getUTCDate();
     var hr=date.getUTCHours();
     var min=date.getUTCMinutes();
     var sec=date.getUTCSeconds();
     return yr+"-"+St2Digits(mon)+"-"+St2Digits(day)+"T"+St2Digits(hr)+":"+  St2Digits(min)+":"+St2Digits(sec)+"Z";
    }

    So two problems here need to be fixed.
    • Marked as answer by MULTISY Friday, July 24, 2009 2:25 PM
    • Edited by MULTISY Friday, July 24, 2009 2:27 PM Typo
    Friday, July 24, 2009 2:25 PM

All replies

  • Could you please let me know more details on your requirement and what you have done?

     

    Per my knowledge, SharePoint OOB cannot filter date using time (HH:MM:SS), if you filter the date with SharePoint Designer, I would help you to move the thread to SharePoint - Design and Customization (http://social.technet.microsoft.com/Forums/en-US/sharepointcustomization/threads)

     

    Thanks.

    -lambert


    Sincerely,
    Lambert Qin | Microsoft TechNet Managed Forum Support
    Posting is provided "AS IS" with no warranties, and confers no rights.
    Friday, July 24, 2009 3:01 AM
  • I think it is a general DateTime.Parse question what is the correct format on a date to filter to include time using filter for a View in a List.

    Example: 7/24/2009 12:00:00 (only 12:00 noon on July 24 2009).

    Should this be considered a bug?  All these years and no one needed to filter by time.
    Friday, July 24, 2009 3:48 AM
  • The issue appears to be related the ListViewWebPart Filter only uses the Date.  Although the Field is Date & Time this is only a UI presentation.

    Creating a View programmically and setting Query where clause using '2009-7-24T12:00:00Z', results in all items for 2009-7-24 it ignore the time component.

    Additionally the JavaScript Function 'DOParseLocaleDate' will only accept YYMMDD formatting, but interestingly the value sent to server would:

    function DOStISODate(date)
    {
     var yr=date.getUTCFullYear();
     var mon=date.getUTCMonth()+1;
     var day=date.getUTCDate();
     var hr=date.getUTCHours();
     var min=date.getUTCMinutes();
     var sec=date.getUTCSeconds();
     return yr+"-"+St2Digits(mon)+"-"+St2Digits(day)+"T"+St2Digits(hr)+":"+  St2Digits(min)+":"+St2Digits(sec)+"Z";
    }

    So two problems here need to be fixed.
    • Marked as answer by MULTISY Friday, July 24, 2009 2:25 PM
    • Edited by MULTISY Friday, July 24, 2009 2:27 PM Typo
    Friday, July 24, 2009 2:25 PM