简体   繁体   English

Subsonic 3.0选择使用DateColumn查询

[英]Subsonic 3.0 select Query using DateColumn

While selecting records using Date-Field i am facing a problem , 在使用日期字段选择记录时,我遇到了问题,

my SQL2005 View (ViewOrders) StarDate column Have 我的SQL2005视图(ViewOrders)StarDate列中有

4/23/2010 12:00:00 AM
4/23/2010 12:00:00 AM
4/23/2010 12:00:00 AM
4/23/2010 12:00:00 AM
4/23/2010 1:07:00 PM

My Code using subsonic 3.0 我的代码使用亚音速3.0

AMDB ctx = new AMDB();
SqlQuery vwOrd = ctx.Select.From<viewOrders>();   
vwOrd = vwOrd.And("StartDate").IsGreaterThanOrEqualTo("04/22/2010");//From date
vwOrd = vwOrd.And("StartDate").IsLessThanOrEqualTo("04/22/2010");// To Date
List<viewOrders> cat = vwOrd.ToList<viewOrders>();

i can able to fetch only first four records, i can't able to fetch the final record which start date contains(4/23/2010 1:07:00 PM). 我只能提取前四个记录,我不能提取包含开始日期的最终记录(2010年4月23日下午1:07:00)。 I think the problem is in the time format.. 我认为问题出在时间格式上。

How can i code in subsonic ,which compare only the date in the date-time column. 我该如何在subsonic中进行编码,它只比较date-time列中的日期。

I Don't need date "Between" method in subsonic, since i can get single date parameter(From date alone). 我不需要在亚音速中使用日期“ Between”方法,因为我可以获取单个日期参数(仅从日期开始)。

As a general rule, getting datetime records within a date range is normally achieved by (psuedo code) 通常,通过(伪代码)获取日期范围内的日期时间记录

DateField >= startdate AND DateField < (EndDate + 1 day)

I'm slightly confused by your example where your date records are all 23-Apr-10, but you seem to be searching for those on 22-Apr-10? 我对您的示例有点困惑,在该示例中,您的日期记录都是10年4月23日,但您似乎正在搜索10年4月22日的记录?

Also, as a general bit of advice, do date comparisons using the format 'YYYYMMDD' - this will cope with different servers in different date formats. 另外,作为一般建议,请使用“ YYYYMMDD”格式进行日期比较-这将处理具有不同日期格式的不同服务器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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