Search
Thursday, August 28, 2008 ..:: Forum ::.. Register  Login
 
  Forum  Templates  Tags & Template...  Comparing Date
Previous Previous
 
Next Next
New Post 2/18/2008 8:49 AM
Resolved
  George
1 posts
No Ranking


Comparing Date 

Hi,

  I can ask you How can I compare Date bettween element and attribute in Tag SELECT:

<Order>

<Car oldValue="1990-10-18">

  1990-10-20

</Car>

</Order>

Something like this is not working corretly:

<wr:if select=”/Order[Car/@oldValue &gt; Car]” type=”DATE” input=”yyyy-MM-dd” pattern=”yyyy-MM-dd” >

</wr:if>

Only for compare, where I use this operator :=, != it goes good.

Thanks

 
New Post 6/24/2008 3:54 PM
  tomasr
9 posts
No Ranking


Re: Comparing Date 

Hi, George

When you just want to see if one date is equal to another, then you can use something like this:

 

<wr:query select="/Order/Car" var="c" datasource="car"/>
<wr:if select="${c}[@oldValue =&apos;1990-10-18&apos;]" datasource="car">
true
</wr:if>

This is a good way to do it if you're iterating through records using a foreach as well.

 

If you want to compare date ranges using greater than and less than, then you can use something like this:

<wr:out select="number(translate(/Order/Car/@oldValue,&quot;-&quot;,&quot;&quot;)) &lt; number(translate(/Order/Car,&quot;-&quot;,&quot;&quot;))" display="false" var="t" datasource="car"/>
<wr:if test="${t}" datasource="car">
true
<wr:else/>false
</wr:if>

As things stand, the if tag doesn't handle date comparisons for greater than and less than, so instead we use xpath functions (number and translate) in the out tag and use the out tag's variable ('t' in the example) to check the result.  The out tag in the example has display="false" so that it doesn't print the result.

- Tomas

 
Previous Previous
 
Next Next
  Forum  Templates  Tags & Template...  Comparing Date
Membership Membership:
Latest New User Latest: louisedean
New Today New Today: 0
New Yesterday New Yesterday: 0
User Count Overall: 55

People Online People Online:
Visitors Visitors: 79
Members Members: 0
Total Total: 79

Online Now Online Now:
All contents copyright (c) 2002 - 2008 by Windward Studios, Inc. All Rights Reserved.   Terms Of Use  Privacy Statement