Manipulating or comparing xs:dateTime values in xpath queries with SelectNodes

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 with a DateTime string, but
that doesn't work.
I've assumed that it is easier to manipulate today's date instead of the
date in my ExpireDate element.

Thankyou in advanced for taking the time to read this and possibly helping

Echo 8


My Code:

Public Function FromElement(ByVal Element As Xml.XmlElement) As Boolean


  Const XmlDateTimeFormat As String = "yyyy-MM-dd\THH:mm:ss\Z"


  Dim DateToCompare As Date = Now.ToUniversalTime.Subtract(New TimeSpan(7,
0, 0, 0))
  Dim DateStr As String = Format(DateToCompare, XmlDateTimeFormat)
  Dim ExpiredStocks As Xml.XmlNodeList
  ' This doesn't work
  ExpiredStocks = Element.SelectNodes("child::NS:Food[ExpireDate < " &
DateStr & "]", nsm)


  Return True

End Function


And my xml data:

  <Stock ID="0001">

  <!-- And so forth -->


eralegrid (2)
10/2/2004 12:56:52 PM
dotnet.xml 7266 articles. 0 followers. Follow

2 Replies

Similar Articles

[PageSpeed] 38

"Echo 8" <> wrote in message news:eMQQiyHqEHA.3988@tk2msftngp13.phx.gbl...
>   ' This doesn't work
>   ExpiredStocks = Element.SelectNodes("child::NS:Food[ExpireDate < " &
> DateStr & "]", nsm)

Could you describe in a little more detail what doesn't work about
that line?

Does it return an empty XmlNodeList, because the example XML
included contains no namespaces or elements with a local name
of Food?  Or have those details just been left out of the example?

(I can't be of much help identifying why the XPath expression doesn't
work when it's inconsistent with the XML.)

Does it throw an exception claiming that there is an invalid qualified
name in the XPath expression, because it sees the colons in the
DateStr as separating a prefix from a local name?  This would be
due to the XPath expression missing ' (single-quotes) around the
DateStr to make it appear as a literal string to XPath.

> I've assumed that it is easier to manipulate today's date instead of the
> date in my ExpireDate element.

You're going to have to manipulate the date in your ExpireDate
element, because Relational Expressions in XPath 1.0 can't
compare strings.  Relational operators in XPath require their
operands to be converted to numbers.

> Is there a simple way of compare dates?

Something like the following may work for you (untried and w/o
warranty, as the details will depend on what your actual XML is),

ExpiredStocks = Element.SelectNodes( _
    String.Format( _
        "//Stock[number(translate(ExpireDate,'TZ:-', '.')) < number('{0}')]", _
        DateTime.Now.ToString( "yyyyMMdd.HHmmss") _
    ), _
    nsm )

The concept is to strip the dashes, colons and trailing Z, and
change the T to a decimal point, then compare it against a
similarly-formatted DateTime parameter.

Derek Harmon

loresayer (274)
10/3/2004 1:25:26 AM
Sorry about that. I tried to simplify everything until just the "essence" of 
what I was trying to get accross. I must have put Food instead of Stock when 
I was typing it. Anyway, it does come up with a XmlXPathException about that 
qualified name thing. I'm not very experienced with .Net, xpath, or xml, made 
obvious by the code I put in the first post.

Anyway, thanks for your swift reply. It's solved my problem. 
eralegrid (2)
10/3/2004 2:55:04 AM

Similar Artilces:

Access Code Pushing Values
I have a customer database with [BillAddress] and [ShipAddress]. I am using a "yes/no" box titled[SameShipAddress?]. To automatically fill [ShipAddress] after checking the "yes/no" box I used this code in the after update event for the check box. If Me![SameShipAddress?] Then If IsNull(Me![BillAddress]) Then Else [ShipAddress] = [BillAddress] End If End If This works for the selected customer, but then pushes the entry [BillAddress] of the previous customer to [ShipAddress] of all of the following customers. Any thoughts? Sounds as...

Query emails coming to a specific domain
Hello; We have about 5 domains on our exchange server that we receive email from. We are in the process of not renewing one of our domains but would like to check to see if email from that domain is still coming through. Is there any way to do that? I tried the Message Tracking Center with the * but it didn't like that. It wanted a specific user. Thanks Check SMTP logs as well. -- Bharat Suneja MVP - Exchange NEW blog location: ---------------------------------------------- <> wrote in message news:...

enter value based on drop down list of another field?
I have an excel 2003 spreadsheet with 3 worksheets. In sheet 1, I created a drop down list in column A based on values in sheet 3, column A (item number). Thisd data comes from sheet 3, where I have column A (Item #'s), column B (Item desc)an Column C (price) In column B of sheet 1, I have Item Descriptions and in column C I have price. I want this to automatically fill in based on what I enter in the column A sheet 1 and it should get the corresponding values from sheet 3 column B and C. I can make the drop down list in sheet 1 column B and C, but some of the descriptions need ...

How do I filter rows based upon a column value
I have a spreadsheet that contains multiple agency id's in a column. When generating reports, I would like to filter per agency and display only the rows associated with that agency. Is there a tutorial or sample on how to do this? Hi It sounds like you are looking for Data / Filter / AutoFilter. Have a look here for some basics: -- Andy. "Jack" <> wrote in message news:eqiU08TVEHA.2988@TK2MSFTNGP10.phx.gbl... > I have a spreadsheet that contains multiple agency id's in a column. When > generati...

comparing 2 similar columns on seperate work sheets in 1 workbook
How can I compare a column from worksheet 1 to a column in worksheet 2 of the same work book? BTW, the cell my have a number or text in it but not formulas "Dan" wrote: > How can I compare a column from worksheet 1 to a column in worksheet 2 of the > same work book? What are you looking for? If you want to find out if each cell in Column A of sheet1 appears in column A of sheet2, you could use a helper column of formulas: =isnumber(match(a1,sheet2!a:a,0)) and drag down And you could use the same kind of formula that will tell you if values in sheet2 appear in sheet1. ...

Comparing cell values then labeling them based on comparision
Hi. I'm trying to find a function or way to compare two cells and then label them according to if one cell is lesser, greater, or the same as the other. I have a large data sheet where I want to compare many pairs of cells and then have them labeled in this way. For example for each pair where the second cell value is larger than the first it would put greater, where the first is larger it would be lesser, etc. Can anybody help me with this? also feel free to email me at Thanks so much for your help. > Hi. I'm trying to find a function or way to compar...

query to make a list of products based on delivery history
I have a table which lists all deliveries made of our product. From this table, I'd like to make a list of all products. My problem is the products will have many duplicates as they can be ordered multiple times and I just want a list showing all the individual products that we offer. -- TIA Try something like: SELECT DISTINCT [our product] FROM [which list all deliveries made]; If you can't figure this out, come back with table and field names. -- Duane Hookom Microsoft Access MVP If I have helped you, please help me by donating to UCP

Sum of values in a form
Folks, I have read numerous threads on this topic, and understand that in order for my Sum() to work I need t ensure all references are made back to the Record Source. I have endeavoured to do this, but am still getting #Error. I am trying to Sum the revenue each tenant provides in a given date range, to give a total revenue figure. If the date range is a whole month, then the expression just takes the value of Rent PCM, and not Rent PCM * No. of Days, which would give some unusual results. My Expression looks like this: =Sum(Nz(IIf([Short Let]=-1,[Rent pcm],IIf(Day([Forms]...

Combo box default value multiautocomplete
Hi All i have a subform with 10 item. The first one is a combo box that can choose the value from a list that is linked to a table with many record. This subform is related to the master form with link master field codice,cognome,nome link child field codice,cognome,nome that are the other items that are not visualize in the subform. These link give me the right connection to the master form. Normally when i choose the value from list (table) i place also all the other item in the subform using this code in after update precedure Me.ISEE.Value = Me.ISEE.Column(0) Me.F_Costo_con_M...

Update Query based on Current Recordset
I have a continuous form with filtered records. I want to run an update query on a field in a table based on the current filtered records on the form. What code would I use to accomplish this task? Any help appreciated in getting me started. NEWER USER, Without a wee bit more information, like what are you trying to update, field names, table names, do you want this attached to a button or an event, etc... The best I can do is... UPDATE SomeTable SET SomeTable.SomeField= WhateverValue WHERE (((SomeTable.SomeOtherFied)=WhateverValue)); Of course, the above would be an ...

Add cell value with mouse click
I want to create a counter, so that every time I click in a certain cell it takes the existing number and adds "1" to it. Is there any way to do this? I'm compiling statistical information, and need to get cumulative counts in various categories as I sort through the data. Hi! Maybe you can use a spinner button for this. Right click any toolbar then select Forms. Click on the spinner button ( it looks like an up arrow on top of a down arrow). Place it near the cell you want increment. Once you have it placed and sized right click on it and select Format Control. Fill in ...

Comparing Databases Before/After Compact & Repair
Hi All, Does anyone have any suggestions on how to compare a database to a copy of itself, compacted vs. uncompacted? I have a vendors product that is currently balooning their included .mdb. I've got a copy of the original (116MB) and a copy I compacted (1.6MB). I'd like to see if I can identify which objects might be at issue. Any suggestions are definitely appreciated. Ciao On Thu, 8 Nov 2007 12:05:51 -0600, "Tony" <||> wrote: There are no tools that I know of that can report the size of uncompacted objects. Typically the bloat...

IIF Query for Numeric Values in Text Field
I’m attempting to flag interest rate spread errors and omissions in a file from a sales database using IIF statements I adapted from another database (I’m a novice at this). The field I’m querying is text format and contains both alpha and numeric values. When I test for a null value the IIF works fine, but when I test for a numeric value I get an #ERROR. Spread Error1: IIf(([Tbl 1 Eligible Closed Deposit Opps Appended]!Spread Is Null),1,0) Spread Error2: IIf(([CCC Fall 2007 Eligible Products]![IB/NIB]="NIB" And [Tbl 1 Eligible Closed Deposit Opps Appended]!Spread<4),1,0...

How to get task manager CPU and default memory column values
I need to return CPU and memory columns for each process in server from web service like task manager shows by default. I tried code below but s.TotalProcessorTime throws Win32exception with stack below. How to get CPU and real memory size from server using web service ? Andrus. static void Processes(StringBuilder sb) { List<Process> processes = new List<Process>(); foreach (Process process in Process.GetProcesses()) processes.Add(process); processes.Sort((a, b) => { ...

Scroll Bar maximum value
I'm designing an interactive chart using a scroll bar object from the Forms Toolbar. The data for my chart gets updated daily and I'd like to have the Maximum Value of the scroll bar reflect the maximum number of data points. Is there a way to do this? The Maximum Value entry does not seem to accept a cell value or formula. I appreciate any help you can offer to solve this problem. Regards, Hi, The Maximum property can not be linked to a cell but you could use a cell to store the value and update the scroller if that value changes. Private Sub Worksheet_Change(ByVal Target...

Linking Values in Worksheets
Is there a simple method of linking a column of values in one worksheet to another worksheet? I can do it manually, one at a time but is there a way of copying the link down the column? (The columns are identical in length) Registers\[Stock Control-Sigma-SMTech.xls]Sheet1'!$C$1369 Registers\[Stock Control-Sigma-SMTech.xls]Sheet1'!$C$1370 Registers\[Stock Control-Sigma-SMTech.xls]Sheet1'!$C$1371 etc, etc Many thanks david Hi David try ='C:\Registers\[Stock Control-Sigma-SMTech.xls]Sheet1'!$C1369 and copy down Frank DavidM wrote: > Is there a simple method of linki...

most often occurent value(s)
I would like to count and determine the most often (10) occurent values (strings) in a column. How can I do that? Thank you very much your help. Tamas, Use a helper column of formulas. For example, in cell B2: =IF(COUNTIF($A$1:A2,A2)=1,COUNTIF(A:A,A2),"") Copy down to match your column, then use Data / Filter.. Autofilter and pick "Top 10" from the dropdown at the top of column B. HTH, Bernie MS Excel MVP "Tamas Konczer" <> wrote in message >I would like ...

#VALUE due to wrong entry
This formula represents dates dd mm yyyy over 3 seperate cells and deducted from a similar formula to work out how many weeks at �s per week. =IF(DATE(K7,J7,I7)-DATE(G7,F7,E7)>=6,229,0 It is used as part of a spreadsheet to work out a monetry deposit for rental. However when `renters` complete this all is ok unless they dont complete as mm (07) but instead type the month as in `July` This then returns #VALUE in the destination cell . Is there a way to change the formula to allow for the `renters` not completing as requested (mm), but still return �s rather than #VALUE I hope I ha...

Insert query with two left outer joins gives "Record is Deleted" m
Hi, I have built an insert query to combine data from 3 tables into one table based on a key value (RA_ID) on a form. Two of the from tables may or may not have data associated with the main from table. So I have coded the select from statement using left outer joins. When I run the query with a row in the first child table but not in the second it works fine but when I run the query with a key value that exists in the 2nd child table but not in the first I get a message saying "record is deleted". Anybody have any ideas what is causing this? Here is the query......... ...

Excel 97: Exporting Cell values to text files.
I was wondering if it is possible to set up a macro where you can sort a set of information once, then export certain cell values to a text file, and then sort it again, and export a different set of cell values to that same text file. I know how to get the Macro going and adding a sort to it, but I'm just not sure 1. if its possible to send cell values to a text file and 2. how one would program that into the macro. Thanks. Here's a couple of links that may give you an idea: Chip Pearson's: Earl Kiosterud's: http://www.tushar-meht...

How to get cell value with the ID from a fomula?
How to get the value from cell of colume A and raw "C3+4", and input to B2? I mean the fomula inputted in cell B2. Thanks. I am not sure what you mean but maybe this will help Regards, Peo Sjoblom "mqiao" wrote: > How to get the value from cell of colume A and raw "C3+4", and input to B2? I > mean the fomula inputted in cell B2. Thanks. ...

In Excel how can I add 90 every value in a row or column? #2
I need to add 90 to every value in a row or column, whichever is vertical ...

Button to reset form values
Hi, I have entered some coding so that when my spreadsheet open, all user values are set to zero (default values). How do I add a button to my worksheet for the user to click on to reset the values to there defaults while working on that sheet :) -- propolis ------------------------------------------------------------------------ propolis's Profile: View this thread: I'd create a named range and then just clear the cells in that named range. Select your...

offsetting Secondary Axes to a cell value
Hi. Here is what i am trying to do. I am trying to create a spreadsheet that will help me graphically display the relationship between Physical harddrive space available and proposed Data chunks allocatted to a particular partition At the moment I am doing it by: Partion1+Partition2...Partion4=TotalDiskSizeAvailable(TDSA) Stacked bar Chart shows each partition up to my I have created another series that shows the data chunks in a stacked bar chart on a secondary axes.... but i would like it to start from the end of Partition1 aligning with beginning of Partition2(where the dat...

Postpone subform query in tabbed control
I have a form containing a tabbed control. One tab in the tab control contains a subform loaded from a query. As I understand it, every time I page from row to row on the main form, the query in the subform runs. I dont want the query to run until the tab is accessed. If I happen to be on the tab, I do want it to run. Hope this makes sensnse. Is this possible? ...