473,320 Members | 2,109 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.

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 9526
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: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
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: 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)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
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
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...

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.