Question : Not recognizing next years dates in  Dataset Search

I have a list of courses stored in an xml file. Some of the start dates are in this year and some are in January of next year. My search of the xml file is not recognizing dates in 2010.
The xml element holding my startdate is :
11/02/2009rtDate>

Here is the code I am using to search the file for the start date that is 2 weeks prior to today OR later than that date:
            ds.ReadXmlSchema(Server.MapPath("~/foster-care/ClassList.xsd"))
            ds.ReadXml(Server.MapPath("~/xml/ClassList.xml"))
            Dim TheDay As String = CStr(DateAdd("d", -14, DateString()))
            Dim strSearch As String = String.Format("StartDate > #{0}#", TheDay)

If today is 12/17/2009 the classes found will be 12/16/2009 and 12/20/2009, which is correct. But there are also classes with start dates of 1/17/2010, which this search does not recognize. Is there something wrong with my code that prevents it from seeing the 2010 dates?

Thank you !

Answer : Not recognizing next years dates in  Dataset Search

Verify that the StartDate column is a date, because if (in the dataset) it is a string-column, then you comparison will be a string comparison instead of a date comparison.  That is probably why dates starting with "01" are never selected when you filter says " > 12/dd/yyyy".

As for the Select method, you have no choice and must convert to a string.  Make sure to format the date correctly (I usually use yyyy/MM/dd format).
Random Solutions  
 
programming4us programming4us