Rick Ratchford wrote:
> #>There is a slight complication with the case where endDate <
> startDate, #>where you want to wrap around to next year. For that, I
> simply need to #>perform calculations modulo a large number - any
> number greater than the #>representation of 12/31 in my scheme. 1300
> is one such number. #>
> #>Igor Tandetnik
> 
> That slight complication is still there though. It works when the
> start < end, but it fails the other way around.

Precisely how does it fail? Seems to work for me:

create table t(month integer, day integer, price integer);
insert into t values(1, 10, 1);
insert into t values(5, 10, 2);
insert into t values(12, 10, 3);

-- select rows between 10/1 and 3/31
select Month, Day, Price
from t, (select 10 as StartMonth, 1 as StartDay, 3 as EndMonth, 31 as EndDay)
where ((Month - StartMonth)*100 + (Day - StartDay) + 1300) % 1300 <
           ((EndMonth - StartMonth)*100 + (EndDay - StartDay) + 1300) % 1300
order by ((Month - StartMonth)*100 + (Day - StartDay) + 1300) % 1300;
12|10|3
1|10|1

Isn't that what you wanted?

Igor Tandetnik


_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to