469,271 Members | 1,737 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,271 developers. It's quick & easy.

XSL Date calculation

Q)How to do the calculation for a date?

Solution applied -->
Defining a template
xsl:template match="DBE:Object" mode="TestTable"

Delivery Date

Latest Possible Order Date

xsl:apply-templates - select="DBE:Attribute[@name='DeliveryDate']/DBE:Date/>

xsl:apply-templates select="DBE:Attribute[@name='LatestOrderDate']"/>


Now i want to calculate "LatestOrderDate" = "DeliveryDate" - 42 days. How should i do it?
Sep 14 '09 #1
4 3761
Dormilich
8,651 Expert Mod 8TB
pretty much as you desribed it: "LatestOrderDate" = "DeliveryDate" - 42
Sep 14 '09 #2
Well,
If the date format for "DeliveryDate" is 2006-01-01 then to calculate "LatestOrderDate" we need to first take out month, day and year and then reduce one month and 12 days.....

Now here Day(Date)=1
so, to reduce 42 we need to reduce the month (exactly 30 days first) from Jan to Dec and then need to calculate by reducing 12 in the month of Nov. So, how to implement the logic as to whatever might be the date entererd for "DeliveryDate"?
Sep 14 '09 #3
Dormilich
8,651 Expert Mod 8TB
there are some useful string and number functions in XPath, that you can use. try to assign that value to a variable.
Sep 14 '09 #4
I am getting the date by traversing through the rows of a table. The moment i get a column (Delivery Date) of that row , i need to reduce 42 from it and display the "Latest Order Date".

Expand|Select|Wrap|Line Numbers
  1.  
  2. <xsl:for-each select="DBE:Attribute[@name='TestTable']/DBE:Table/DBE:TableRow"> 
  3. <tr>
  4.  <xsl:for-each select="child::DBE:TableData[count(preceding-sibling::DBE:TableData)+1=1]"> 
  5. <td> <xsl:apply-templates/> <!-- I get the Delivery Date here --> </td> 
  6. </xsl:for-each> 
  7. <td> LatestOrderDate </td> 
  8.  
Please let me know incase of any example to do so.
Also is it easy to define the logic in jsp and use it in xsl. Which way is recommended?
Sep 16 '09 #5

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

4 posts views Thread by Manny Chohan | last post: by
1 post views Thread by mene | last post: by
4 posts views Thread by Richard Hollenbeck | last post: by
3 posts views Thread by Lindie | last post: by
2 posts views Thread by smcgrath via AccessMonster.com | last post: by
6 posts views Thread by krishnakant Mane | last post: by
16 posts views Thread by W. eWatson | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.