tags:

views:

54

answers:

1

I'm trying to calculate a year based on a year starting 6th April.

Using EXSLT I can get the year based on a normal January start:

date:formatDate(date:add(date:date(), '-P6Y'), 'yyyy')

How can I do the same but for a year starting 6th April.

Thanks.

A: 

Something like this

 <xsl:choose>
   <xsl:when test="(date:month-in-year() = 4 and date:day-in-month() <= 6) or (date:month-in-year() < 4)">
     <xsl:value-of select="date:formatDate(date:add(date:date(), '-P7Y'), 'yyyy')" />
   </xsl:when>
   <xsl:otherwise>
     <xsl:value-of select="date:formatDate(date:add(date:date(), '-P6Y'), 'yyyy')" />
  </xsl:otherwise>
</xsl:choose>
TFD