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

Selecting on date

My XML data contains elements with a date attribute. I need to write
an XSLT transformation that only selects the elements for the current
month. Is that possible with XSLT only, or should I preselect the data
a different way?
Thanks
Jun 27 '08 #1
2 1299
pr
Peter Laman wrote:
My XML data contains elements with a date attribute. I need to write
an XSLT transformation that only selects the elements for the current
month. Is that possible with XSLT only, or should I preselect the data
a different way?
It's simple if your dates are in a consistent format, for example
'yyyy-mm-dd'. In XSLT 1.0:

<xsl:template match="element[starts-with(@date, '2008') and
substring(@date, 6, 2) = '04']">

or using a key:

<xsl:key name="months" match="element[starts-with(@date, '2008')]"
use="substring(@date, 6, 2)"/>

...

<xsl:apply-templates select="key('months', '04')"/>

Jun 27 '08 #2
Peter Laman wrote:
My XML data contains elements with a date attribute. I need to write
an XSLT transformation that only selects the elements for the current
month. Is that possible with XSLT only, or should I preselect the data
a different way?
Pass in the current month/date as a parameter, then use string
processing to compare the relevant parts of dates.
Or move up to XSLT 2.0 where you have xs:date/xs:dateTime data type
support and functions like current-date and month-from-date.
--

Martin Honnen
http://JavaScript.FAQTs.com/
Jun 27 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Jagdip Singh Ajimal | last post by:
I have 6 columns, all with dates within them, i.e. Proposed Start Date 1 Proposed Start Date 2 Proposed Start Date 3 Proposed Finish Date 1 Proposed Finish Date 2 Proposed Finish Date 3 ...
2
by: Rene | last post by:
I have a master "attendance" report that also has two "attendance" sub-reports...each collecting data from a different group...and totaling those present at the end. I chose sub-reports because...
1
by: erkwong | last post by:
Hello, What would be the simplist way to get the current date to populate a text box upon the de-selecting of a check-box (aka making the check box field false?) This is basically what I had...
1
by: Ramesh | last post by:
hi, I am selecting fields from three table for manupulating data and i want to display total number of records selected. But i am always getting -1 value, eventhough 1000 of records are selected....
3
by: larry mckay | last post by:
anyone have the code to select and listview item or row (subitems) after a doubleclick event from a listview. *** Sent via Developersdex http://www.developersdex.com *** Don't just participate...
1
by: vunderusaf | last post by:
I have a listbox on a form that is selecting using named FinalQuery: SELECT ., ., . FROM FinalQuery; Now I have a text field with a date on this form and I'd like to use that date as the...
9
by: ice | last post by:
Hello, I have a couple of tables. The client tables and the contacted tables. I am not sure how to start on this, what I need is a way to query all my clients then show any client that the...
2
by: movieking81 | last post by:
If someone could help me with this, that would be great. I need to select a number of records from an SQL table based on a date range, so I started with this select. <html> <code> resultssql =...
4
by: tone | last post by:
Hi, need some help. Got table A with two columns: type DATE, VALUE Got table B with two columns: type DATE, VALUE Now the thing is to update table A with the values from table B. For each...
1
by: archcool | last post by:
I want to display new empty text fields within the same form after selecting an option from a combobox. here is the form Filter by:todays date,from date ---- in a combobox when from date is...
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: 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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.