问题描述
在foxpro数据库中,如何编写选择查询以查看特定时间范围内的数据。谁能举个例子。
解决方法
您只需编写它,就像处理任何SQL数据库一样。唯一不同的是参数的语法。例如,下面的查询检索在2020年7月进行的所有交易:
local ltFrom,ltUpTo
ltFrom = DateTime(2020,7,1)
ltUpTo = DateTime(2020,8,1) && Midnight
select * from myTable ;
where transactionDatetime >= ?m.ltFrom and ;
transactionDatetime < ?m.ltUpTo ;
into cursor crsResult ;
nofilter
browse
,
要扩展Cetin的日期范围查询,还可以查询包括时间部分的范围:
ltFrom = DateTime(2020,1,0) && midnight
ltUpTo = DateTime(2020,14,03,51) && 2:03:51 pm
*ltFrom = DateTime(2020,0) && midnight
*ltUpTo = DateTime(2020,3,11,59,59) && 1 second before noon 2 days later
SELECT hostname,timestamp FROM gsm WHERE timestamp BETWEEN ?ltfrom AND ?ltupto INTO CURSOR crsResult NOFILTER ORDER BY timestamp
select * from myTable ;
where transactionDatetime between ?m.ltFrom and ?m.ltUpTo ;
into cursor crsResult ;
nofilter
browse
上面有2个时间范围:
- 2020年8月1日午夜至下午2:03:51
- 2020年8月1日午夜至2020年8月3日上午11:59:59(注释)