[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Calculate Monthly Recuring dates

Subject: Calculate Monthly Recuring dates
From: Adam Retter <adam.retter@xxxxxxxxxxxx>
Date: Tue, 30 Jan 2007 15:34:56 +0000
 Calculate Monthly Recuring dates
I do not know if my brain is on a go slow this afternoon or what, but I
am really struggling with this one, so perhaps someone has already tried
or knows how to do this.

(BTW - my XSLT Processor is Saxon 8 and I am already making use of EXSLT
for other date related operations).

Scenario -

An event happens on the Same day of the same Week every month.
So an event on the 4th February 2006, happens on the 1st Saturday of
every month.

I want to take today's date and from that work out the next event
occurrence, the event could be this month if the date has not passed, or
if not then next month.

I have at the moment something like this -

<xsl:variable name="start" value="xs:date('2006-02-04')"/>
<xsl:variable name="startDayInWeek" select="date:day-in-week($start)"/>
<xsl:variable
name="thisDayInWeek"select="date:day-in-week(current-date())"/>
<xsl:variable name="startWeekInMonth"
select="date:week-in-month($start)"/>
<xsl:variable name="thisWeekInMonth"
select="date:week-in-month(current-date())"/>
    
        <xsl:choose>
            <xsl:when test="$thisWeekInMonth &lt; $startWeekInMonth and
$thisDayInWeek &lt;= $startDayInWeek">
                <!-- 1) TODO: event is yet to occur this month,
calculate the date for this month -->
            </xsl:when>
            <xsl:otherwise>
                <!-- 2) TODO: event has already occured this month,
calculate the date for next month -->
	</xsl:otherwise>
</xsl:choose>


Now the parts where I am struggling, I have marked with TODO and what
needs to be done. So for 1) I need a mechanism for working out the date
for the 1st Saturday of this month. and for 2) I need a mechanism for
working out the 1st saturday of next month. How can I acheive this?

Thanks very much

-- 
Adam Retter

Principal Developer
Devon Portal Project
Room 310
County Hall
Topsham Road
Exeter
EX2 4QD

t: 01392 38 3683
f: 01392 38 2966
e: adam.retter@xxxxxxxxxxxx
w: www.devonline.gov.uk

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.