none
DVWP count rows between date range RRS feed

  • Question

  • I have a milestone list in which all of the entries have 1 of 6 titles, a due date and a completed date. I've created a table that has a row for each title and then a column for each month. I currently have each column built to count the number of entries based on the title but I'm running into difficulties trying to make it count based on the title and then within a givin date range.

    So for example:

    Milestone 1 has 103 entries, 5 of those are due in the month of January how can I get my xpath expression to display the number 5.

    I tried getting it to count for a specifc date using:

    <xsl:variable name="MS1Jan" select="count(/dsQueryResponse/Rows/Row[normalize-space(@Milestone) = 'Milestone 1' and ddwrt:FormatDate(string(@Due_x0020_Date),1033,1) = string('2009-01-14') ])" />
    I've tried using a number of variations of the above example using the formate date option, string, translate and have gotten either 0 or 97. I'm completely baffled why I get the number 97.

    I've also tried using xsl:for-each to see if I could nest a bunch of quiries to give me the desired result to no avail.
    Monday, June 22, 2009 6:19 PM

Answers

  • Nick:

    You'll want to match your date formats.
    ddwrt:FormatDate(string(@Due_x0020_Date),1033,1)
    will returns something like:
    6/22/2009
    You'll want something more like this:
    ddwrt:FormatDateTime(string(@Due_x0020_Date), 1033, 'yyyyMMdd')
    which returns:
    20090622
    and then compare it to
    '20090114'

    M.
    Marc D Anderson - Sympraxis Consulting LLC - Marc D Anderson's Blog
    • Marked as answer by Nick Ortiz Monday, June 22, 2009 8:05 PM
    Monday, June 22, 2009 7:53 PM

All replies

  • Nick:

    You'll want to match your date formats.
    ddwrt:FormatDate(string(@Due_x0020_Date),1033,1)
    will returns something like:
    6/22/2009
    You'll want something more like this:
    ddwrt:FormatDateTime(string(@Due_x0020_Date), 1033, 'yyyyMMdd')
    which returns:
    20090622
    and then compare it to
    '20090114'

    M.
    Marc D Anderson - Sympraxis Consulting LLC - Marc D Anderson's Blog
    • Marked as answer by Nick Ortiz Monday, June 22, 2009 8:05 PM
    Monday, June 22, 2009 7:53 PM
  • Sweet that worked, I knew it was a problem with the the way the date was formated just didnt know enough about the FormatDate option to fix it.
    Monday, June 22, 2009 8:05 PM