strWhere:='Where LoginDate between '''+Format( DateToStr(dtpEnd.Date),['yyyy-mm-dd']) +''' and '''+Format( DateToStr(dtpEnd.Date),['yyyy-mm-dd'])+'''';
strWhere:='Where LoginDate between '+DateToStr(dtpStart.Date) +' and '+DateToStr(dtpEnd.Date);
把dtpEnd,dtpStart 的time属性设为00:00:00strWhere:='Where LoginDate between '''+DateToStr(dtpStart.Datetime) +''' and '''+DateToStr(dtpEnd.Datetime+1)+'''';
strWhere:='Where LoginDate between '''+DateTimeToStr(dtpStart.Date) +''' and '''+DateTimeToStr(dtpEnd.Date)+'''';
应该为 strWhere:='Where convert(char(10),LoginDate,21) >= '''+DateToStr(dtpStart.Datetime) +''' and convert(char(10),LoginDate,21) <= '''+DateToStr(dtpEnd.Datetime)+'''';
再试一下把dtpEnd,dtpStart 的time属性设为00:00:00sql.add('LoginDate>='''+DateToStr(dtpStart.Datetime) +''' and '+'LoginDate<'''+DateToStr(dtpEnd.Datetime+1)+'''');
where time between startdate to enddate
从系统设置的角度,你可以在控制面板的区域设置中进行设置 从程序的角度来看,我以前访问Oracle时很少用Between,而是经常用">= and <=",另外在Oracle中转换日期格式用To_char(datefd,'yyyymmdd') 你在试一下
formatdatetime('yyyy-mm-dd',Date) + ' ' + formatdatetime('hh:mm:ss',time) + '"
2:显示时要:
TDateTimeField(Query1.Fields[3]).DisplayFormat :='yyyy/mm/dd hh:mm:ss';
方法一:将DateToStr换成FormatDateTime('yyyy-mm-dd',dtpStart.Date);方法二:在控制面板中设置系统日期时间的长短格式.
strWhere:='Where LoginDate between '''+Format( DateToStr(dtpEnd.Date),['yyyy-mm-dd'])
+''' and '''+Format( DateToStr(dtpEnd.Date),['yyyy-mm-dd'])+'''';
+' and '+DateToStr(dtpEnd.Date);
+''' and '''+DateToStr(dtpEnd.Datetime+1)+'''';
+''' and '''+DateTimeToStr(dtpEnd.Date)+'''';
strWhere:='Where convert(char(10),LoginDate,21) >= '''+DateToStr(dtpStart.Datetime)
+''' and convert(char(10),LoginDate,21) <= '''+DateToStr(dtpEnd.Datetime)+'''';
+''' and '+'LoginDate<'''+DateToStr(dtpEnd.Datetime+1)+'''');
从程序的角度来看,我以前访问Oracle时很少用Between,而是经常用">= and <=",另外在Oracle中转换日期格式用To_char(datefd,'yyyymmdd')
你在试一下