473,320 Members | 1,961 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,320 software developers and data experts.

Calculating Number of days between two dates

I have two dates: 1. mfg date
2. incident date
I need to calculate the number of days 2 and 1.
This is what i have:

<xsl:when test="Complaint/V_CXP_CUSTOMER_PXP/CXP_MFG_DATE ='CXP_MFG_DATE'">
<C20_Age_of_Device><xsl:value-of select="V_CXP_CUSTOMER_PXP/CXP_AWARE_DATE='CXP_AWARE_DATE - CXP_MFG_DATE'"></C20_Age_of_Device>

that is to say, if the mfg date is available, then calculate the number of days between the incident date and mfg date. am i using the correct syntax? I am new to this, so is there a simple way of doing it? The fields are obtained from a form.
thanks

bernie
Aug 4 '07 #1
1 12834
jkmyoung
2,057 Expert 2GB
I think you wanted something like:
Expand|Select|Wrap|Line Numbers
  1. <xsl:when test="Complaint/V_CXP_CUSTOMER_PXP/CXP_MFG_DATE[. != '']">
When the CXP_MFG_DATE exists, and is not blank, get this value:
Expand|Select|Wrap|Line Numbers
  1. V_CXP_CUSTOMER_PXP/CXP_AWARE_DATE - 
  2. V_CXP_CUSTOMER_PXP/MFG_AWARE_DATE
--------
However if you are using XSLT 1.0, unless your dates are stored as integers counting the number of days, this won't work.
If you are using XSLT 2.0, you can use the date functions:
http://www.w3schools.com/xpath/xpath...s.asp#datetime , eg:
Expand|Select|Wrap|Line Numbers
  1. days-from-duration(subtract-dateTimes(V_CXP_CUSTOMER_PXP/CXP_AWARE_DATE, V_CXP_CUSTOMER_PXP/MFG_AWARE_DATE))
If XSLT 2.0 is not an option, check out EXSLT:
http://www.exslt.org/date/index.html , eg:
Expand|Select|Wrap|Line Numbers
  1. <xsl:call-template name="date:difference">
  2.    <xsl:with-param name="start" select="V_CXP_CUSTOMER_PXP/CXP_AWARE_DATE" />
  3.    <xsl:with-param name="end" select="V_CXP_CUSTOMER_PXP/MFG_AWARE_DATE" />
  4. </xsl:call-template>
Aug 7 '07 #2

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

Similar topics

4
by: Hans Gruber | last post by:
Hi all, I have been struggling with a problem all day, I have been unable to come up with a working solution. I want to write a function which takes 2 unix timestamps and calculates the...
4
by: John | last post by:
hey all..... alright, I am frusterated to the point of throwing my machine out the window (this board went down, trying to find stuff on google, this has been a nightmare) so I hope you guys can...
10
by: riki | last post by:
hello, i need to calculate num of days between 2 dates... i get separate parts of dates from html form, then i need to "make" begining and ending date and calculate difference between them......
2
by: celsius | last post by:
Hi folks, Al Bowers wrote this program on comp.lang.c Date: 2001-07-09 13:41:58 PST #include <stdio.h> int isleap (unsigned yr); static unsigned months_to_days (unsigned month); static long...
2
by: Scott | last post by:
Hi All I have an application that has a start date and a finish date I need to calculate the number of days from the start date to the end date and then display this in a read only text box... ...
4
by: Yotam | last post by:
Hi, I need some help with JS. I will be grateful, if you can help me out. I have two date fields (check in, check out) and "number of days" field. I want the script to calculate automatically...
9
by: clintonb | last post by:
I'm looking for a way to calculate the number of days between two dates using standard C++ functions. Would it be as simple as just using the difftime() function and then dividing that result by...
8
by: =?Utf-8?B?QWw=?= | last post by:
I am working in vb2005. how can I calculate business days (not including holidays and weekends) between 2 dates? thanks Al
5
by: jjkeeper | last post by:
G'day, I'm currently working on an annual leave database for the company, so far so good, till they want the database to be able to identify public holidays and prevent reducing the employee's...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
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: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.