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

XPath problem with dateTime strings comparison

Hello,

I've got an XML file saved from DataSet. One table has datetime column
(datatype - xs:dateTime). XML file fragment for example:

<Root>
<Element>2004-03-15T00:00:00.0000000+01:00</Element>
<Element>2004-03-16T00:00:00.0000000+01:00</Element>
<Element>2004-03-17T00:00:00.0000000+01:00</Element>
<Element>2004-03-18T00:00:00.0000000+01:00</Element>
</Root>

I'm trying to get MyXmlNodeList using
MyXmlDataDocument.DocumentElement.SelectNodes(MyXP athString) method, where
MyXPathString, for example, should look like:
"/Root/Element[DateFrom >= '2004-03-16T00:00:00.0000000+01:00']"

Problem: None of nodes are selected/returned if I use ">=" or "<="
comparison operators, but I could get a result using "=" operator.

Question: How to compare datetime strings?
Thank you,
Viktor
Nov 12 '05 #1
4 9530
See the following article:
http://www.biglist.com/lists/xsl-lis.../msg00492.html

"Viktor Jevdokimov" <vj*********@hotmail.com> skrev i meddelandet
news:uL**************@TK2MSFTNGP09.phx.gbl...
Hello,

I've got an XML file saved from DataSet. One table has datetime column
(datatype - xs:dateTime). XML file fragment for example:

<Root>
<Element>2004-03-15T00:00:00.0000000+01:00</Element>
<Element>2004-03-16T00:00:00.0000000+01:00</Element>
<Element>2004-03-17T00:00:00.0000000+01:00</Element>
<Element>2004-03-18T00:00:00.0000000+01:00</Element>
</Root>

I'm trying to get MyXmlNodeList using
MyXmlDataDocument.DocumentElement.SelectNodes(MyXP athString) method, where
MyXPathString, for example, should look like:
"/Root/Element[DateFrom >= '2004-03-16T00:00:00.0000000+01:00']"

Problem: None of nodes are selected/returned if I use ">=" or "<="
comparison operators, but I could get a result using "=" operator.

Question: How to compare datetime strings?
Thank you,
Viktor

Nov 12 '05 #2
And use XmlDocument instead of XmlDataDocument
Yan

"Magnus" <Ma********@discussions.microsoft.com> wrote in message
news:OX**************@TK2MSFTNGP11.phx.gbl...
See the following article:
http://www.biglist.com/lists/xsl-lis.../msg00492.html

"Viktor Jevdokimov" <vj*********@hotmail.com> skrev i meddelandet
news:uL**************@TK2MSFTNGP09.phx.gbl...
Hello,

I've got an XML file saved from DataSet. One table has datetime column
(datatype - xs:dateTime). XML file fragment for example:

<Root>
<Element>2004-03-15T00:00:00.0000000+01:00</Element>
<Element>2004-03-16T00:00:00.0000000+01:00</Element>
<Element>2004-03-17T00:00:00.0000000+01:00</Element>
<Element>2004-03-18T00:00:00.0000000+01:00</Element>
</Root>

I'm trying to get MyXmlNodeList using
MyXmlDataDocument.DocumentElement.SelectNodes(MyXP athString) method,
where
MyXPathString, for example, should look like:
"/Root/Element[DateFrom >= '2004-03-16T00:00:00.0000000+01:00']"

Problem: None of nodes are selected/returned if I use ">=" or "<="
comparison operators, but I could get a result using "=" operator.

Question: How to compare datetime strings?
Thank you,
Viktor


Nov 12 '05 #3
As I thought. Thanks.

"Magnus" <Ma********@discussions.microsoft.com> wrote in message
news:OX**************@TK2MSFTNGP11.phx.gbl...
See the following article:
http://www.biglist.com/lists/xsl-lis.../msg00492.html

"Viktor Jevdokimov" <vj*********@hotmail.com> skrev i meddelandet
news:uL**************@TK2MSFTNGP09.phx.gbl...
Hello,

I've got an XML file saved from DataSet. One table has datetime column
(datatype - xs:dateTime). XML file fragment for example:

<Root>
<Element>2004-03-15T00:00:00.0000000+01:00</Element>
<Element>2004-03-16T00:00:00.0000000+01:00</Element>
<Element>2004-03-17T00:00:00.0000000+01:00</Element>
<Element>2004-03-18T00:00:00.0000000+01:00</Element>
</Root>

I'm trying to get MyXmlNodeList using
MyXmlDataDocument.DocumentElement.SelectNodes(MyXP athString) method, where MyXPathString, for example, should look like:
"/Root/Element[DateFrom >= '2004-03-16T00:00:00.0000000+01:00']"

Problem: None of nodes are selected/returned if I use ">=" or "<="
comparison operators, but I could get a result using "=" operator.

Question: How to compare datetime strings?
Thank you,
Viktor


Nov 12 '05 #4
Yan Leshinsky wrote:
And use XmlDocument instead of XmlDataDocument


Or even XPathDocument if you only need to query data, not edit.

--
Oleg Tkachenko [XML MVP]
http://blog.tkachenko.com
Nov 12 '05 #5

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

Similar topics

16
by: Donnal Walter | last post by:
I was very surprised to discover that >>> import datetime >>> x = datetime.date(2004, 9, 14) >>> y = datetime.datetime(2004, 9, 14, 6, 43, 15) >>> print x == y True How can these two...
7
by: steve bull | last post by:
I have the following code snippet to read the colorRange attributes for the colorRangeSwatch in the xml file listed below. string expr = "/swatches/colorRangeSwatch/colorRange";...
2
by: dingbat | last post by:
Losing my marbles here (some sleep would help!) Why are the following XPath comparisons both returning false ? <xsl:value-of select="string('2005-09-22T12:43:23') &gt;...
1
by: Hollywood | last post by:
I have the following XSD created in VS.NET 2003: <?xml version="1.0" encoding="utf-8" ?> <xs:schema id="ReferralSchama" targetNamespace="http://test.org/Referral"...
2
by: Echo 8 | last post by:
Is there a simple way of compare dates? I am trying to create a list of perishable stock in an inventory that is near or past its expiration date. I've tried telling it to compare a node's value...
4
by: elziko | last post by:
Hi I have two date times that I belive to be equal. However, when I do a comparison I find that date1 is less than date2... Console.WriteLine(date1.ToString("dd/MM/yyyy HH:mm:fffffff") + " - " +...
2
by: Nishad | last post by:
Is anybody know how to write xpath for string Value Comparisons thank you
3
by: jmagaram | last post by:
I have a DataSet I want to work with as Xml using XmlDataDocument. I can't figure out how to query the resultant Xml using XPath. From the following XML below, what XPath query will return the list...
3
by: MikeL | last post by:
I'm using .Net 2.0. I realize that this means XPath 1.0 (which is ridiculous). So here's a document that I have that's not on disk but held in a variable (I queried an Exchange appointment...
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: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...

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.