473,372 Members | 869 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,372 software developers and data experts.

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 3975
Dormilich
8,658 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,658 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

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

Similar topics

4
by: Manny Chohan | last post by:
Hi Can anyone tell me how i can calculate yesterday date using asp? Thanks manny
1
by: Raghu | last post by:
Hello... I am running into a problem while running a query..can some1 help.. this is the query : ************** SELECT * from Table S where S.dtDate1 BETWEEN...
1
by: mene | last post by:
I have a field that contains date information, and sometimes time information as well. I would like to be able to take that date and do a calculation on it. Here are some examples of what is in...
4
by: Richard Hollenbeck | last post by:
I'm trying to write some code that will convert any of the most popular standard date formats twice in to something like "dd Mmm yyyy" (i.e. 08 Jan 1908) and compare the first with the second and...
3
by: Lindie | last post by:
We need to track how often a book has been loaned. We enter the dates and need an automatic calculation how often in the preceeding 12 months it has been taken out. box 1: today's date box 2:...
2
by: smcgrath via AccessMonster.com | last post by:
I have a table listing accounts with a closed date - our Trial balance drops the account after 7 days but our database keeps the record forever - How do I calculate the end of month less 7 days so...
4
by: jamesyreid | last post by:
Hi, I'm really sorry to post this as I know it must have been asked countless times before, but I can't find an answer anywhere. Does anyone have a snippet of JavaScript code I could borrow...
1
by: c8tz | last post by:
This is a query I have created that picks up the top 3 dates for this data (for example) : Tree Pos2 Date 1 15 23/08/2005 1 20 12/02/2006 1 32 15/10/2006 ...
6
by: krishnakant Mane | last post by:
hello, I am strangely confused with a date calculation problem. the point is that I want to calculate difference in two dates in days. there are two aspects to this problem. firstly, I can't get...
16
by: W. eWatson | last post by:
Are there some date and time comparison functions that would compare, say, Is 10/05/05 later than 09/22/02? (or 02/09/22 format, yy/mm/dd) Is 02/11/07 the same as 02/11/07? Is 14:05:18 after...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.