I am using linq to XML in C#
I have an XML where records are stored
<ID>1</ID>
<Date>01/12/2012 </Date>
<value>10</value>
<ID>2</ID>
<Date>02/12/2012 </Date>
<value>10</value>
<ID>3</ID>
<Date>03/12/2012 </Date>
<value>10</value>
I am trying to get the records for selected FromDate to ToDate.
for example between fromDate > 01/12/2012 & endDate < 03/12/2012
so I am writing the query as
var r = from pro in d.Descendants("products")
where
(DateTime)pro.Element("Date") < Convert.ToDateTime(dateTimePickerToDate.Text) && (DateTime)pro.Element("Date") > Convert.ToDateTime(dateTimePickerFromDate.Text)
select pro;
foreach (var p in r)
{
currentproductID = p.Element("ID").Value;
}
but it is giving an error "string not recognized as a valid datetime"
Any idea why I am getting an error?
I have an XML where records are stored
<ID>1</ID>
<Date>01/12/2012 </Date>
<value>10</value>
<ID>2</ID>
<Date>02/12/2012 </Date>
<value>10</value>
<ID>3</ID>
<Date>03/12/2012 </Date>
<value>10</value>
I am trying to get the records for selected FromDate to ToDate.
for example between fromDate > 01/12/2012 & endDate < 03/12/2012
so I am writing the query as
var r = from pro in d.Descendants("products")
where
(DateTime)pro.Element("Date") < Convert.ToDateTime(dateTimePickerToDate.Text) && (DateTime)pro.Element("Date") > Convert.ToDateTime(dateTimePickerFromDate.Text)
select pro;
foreach (var p in r)
{
currentproductID = p.Element("ID").Value;
}
but it is giving an error "string not recognized as a valid datetime"
Any idea why I am getting an error?