1 minute read
Andy Lewis over at the Microsoft SharePoint Designer Team Blog has a nice post about how to do Filtering and Formatting with Date Values. The best part of the post (it is FULL of useful information) is a set of utility templates that do some useful calculations on dates:
getDateFromDays Outputs the date that is $Delta days from $BaseDate
convertCalcDateValue Formats a calculated date field value in ISO format
getDayDelta Returns the difference in days between paramDateA and paramDateB
getDateRange From a base date it is given, returns START OR END date for MONTH OR QUARTER (LAST, THIS, or NEXT)
isLeapYear Is this paramYear a leap year?
getQuarterMonthBoundary Return START or END date for the quarter inside which paramMonth exists.
countDaysInDate How many days are there between 0 and paramDate (NOT INCLUDING leap-year days)?
countDaysInDateWithLeapYearDays How many days are there between 0 and paramDate (INCLUDING leap-year days)?
ConvertMonthToDays How many days are in paramMonth (including leap-year day if paramYear is supplied)?
ConvertMonthToTotalDays How many days are there from beginning of year through paramMonth (including leap-year day if paramYear is supplied)?
ConvertDaysToMonth What is the month when paramDays have passed since beginning of year?
This set of utility functions can be built upon for all sorts of useful date manipulation, which can be difficult in XSL.