Home All Groups Group Topic Archive Search About

how pass Date vaiable to XPath query

Author
6 Dec 2006 3:54 PM
martin1
Hi,All


I want to pass Date varible value to XPATh query (see code below), it i snot
work, can anyone help this out? Thanks. Martin

Dim currentDate As Date = CDate("5/29/2006")

adoCmd.CommandText = "<Root xmlns:sql=""urn:schemas-microsoft-com:xml-sql""
>" & _
           "<sql:xpath-query mapping-schema = schema1.xsd/Node1[ Date ='" &
currentDate & "' ] </sql:xpath-query>"  & _
           " </Root>"

Author
6 Dec 2006 7:32 PM
martin1
I figure out now.

Show quoteHide quote
"martin1" wrote:

> Hi,All

>
> I want to pass Date varible value to XPATh query (see code below), it i snot
> work, can anyone help this out? Thanks. Martin
>
>  Dim currentDate As Date = CDate("5/29/2006")
>
> adoCmd.CommandText = "<Root xmlns:sql=""urn:schemas-microsoft-com:xml-sql""
> >" & _
>            "<sql:xpath-query mapping-schema = schema1.xsd/Node1[ Date ='" &
> currentDate & "' ] </sql:xpath-query>"  & _
>            " </Root>"
Author
7 Dec 2006 11:21 AM
Phill W.
And, for the benefit of the next person(s) who have to do the the same
thing...

    How???

Regards,
    Phill  W.


martin1 wrote:
Show quoteHide quote
> I figure out now.
>
> "martin1" wrote:
>
>> Hi,All
>> 
>>
>> I want to pass Date varible value to XPATh query (see code below), it i snot
>> work, can anyone help this out? Thanks. Martin
>>
>>  Dim currentDate As Date = CDate("5/29/2006")
>>
>> adoCmd.CommandText = "<Root xmlns:sql=""urn:schemas-microsoft-com:xml-sql""
>>> " & _
>>            "<sql:xpath-query mapping-schema = schema1.xsd/Node1[ Date ='" &
>> currentDate & "' ] </sql:xpath-query>"  & _
>>            " </Root>"
Author
7 Dec 2006 1:58 PM
martin1
convert date to string  and then pass by strDate = Date.ToString("yyyy-mm-dd")

Show quoteHide quote
"Phill W." wrote:

> And, for the benefit of the next person(s) who have to do the the same
> thing...
>
>     How???
>
> Regards,
>     Phill  W.
>
>
> martin1 wrote:
> > I figure out now.
> >
> > "martin1" wrote:
> >
> >> Hi,All
> >> 
> >>
> >> I want to pass Date varible value to XPATh query (see code below), it i snot
> >> work, can anyone help this out? Thanks. Martin
> >>
> >>  Dim currentDate As Date = CDate("5/29/2006")
> >>
> >> adoCmd.CommandText = "<Root xmlns:sql=""urn:schemas-microsoft-com:xml-sql""
> >>> " & _
> >>            "<sql:xpath-query mapping-schema = schema1.xsd/Node1[ Date ='" &
> >> currentDate & "' ] </sql:xpath-query>"  & _
> >>            " </Root>"
>
Author
7 Dec 2006 6:57 PM
Chris Dunaway
Phill W. wrote:
Show quoteHide quote
> And, for the benefit of the next person(s) who have to do the the same
> thing...
>
>     How???
>
> Regards,
>     Phill  W.
>
>
> martin1 wrote:
> > I figure out now.
> >
> > "martin1" wrote:
> >
> >> Hi,All
> >>
> >>
> >> I want to pass Date varible value to XPATh query (see code below), it i snot
> >> work, can anyone help this out? Thanks. Martin
> >>
> >>  Dim currentDate As Date = CDate("5/29/2006")
> >>
> >> adoCmd.CommandText = "<Root xmlns:sql=""urn:schemas-microsoft-com:xml-sql""
> >>> " & _
> >>            "<sql:xpath-query mapping-schema = schema1.xsd/Node1[ Date ='" &
> >> currentDate & "' ] </sql:xpath-query>"  & _
> >>            " </Root>"

In that context, look at the ToString method of the DateTime class.
You can pass it formatting information like this:

currentDate.ToString("yyyyMMdd")   =>     20061207

Hope this helps

Chris