简体   繁体   中英

Selecting DataRows with valuetype DateTime based on only year

I need to select a 'DateTime' field from my DataSet based on only the year. (To begin with, may expand to year + month later)

The program exits with an error when it is run, and I'm unsure what the real query would be in this case. - I do NOT have access to the database to do it in the query, so it has to be in the DataSet

IEnumerable<DataRow> selectedRows = myLicenseInfoDataSet.Tables[0].Select("CreationDate = #" + startDateTime.Year.ToString() + "#");

通过执行以下操作解决了我的问题:

                ICollection<DataRow> selectedRows = myLicenseInfoDataSet.Tables[0].Select("CreationDate >= #" + startDateTime + "# AND CreationDate <= #" + startDateTime.AddYears(1).AddDays(-1) + "#");


The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM