Flourish PHP Unframework
This is an archived copy of the forum for reference purposes

active record date range

posted by netpork 7 years ago

I have a table with column bpr_datetime, and for example 20 records in it where date ranges from 2012-02-22 to 2012-07-04.

i have tried:

	$bp = fRecordSet::build(
				'bpr_datetime>=' => '2012-02-22',
				'bpr_datetime<=' => '2012-07-04',
				'bpr_usr_id=' => 1

But, I only get 19 records, instead of 20. Am I using lte and gte operators the right way?

Thanx in advance.

ps. flourish php lib is a goldmine! :)

Yes, you are, although, if as your column name implies, I'd imagine you actually want something that takes hours, minutes, and seconds into account. I don't think Flourish does much with string dates other than converting them to fDates (although it should be possible to also check directly against an fDate).

fDate, in it's most basic sense, uses strtotime() to make things easier. That being said what you are looking for is probably actually resolving to the following:

2012-02-22 00:00:00

<= 2012-07-04 00:00:00

This means anything which is schedule at any other time from 12:00 am on the 4th of July is being excluded. Realistically what you want is the following:

2012-02-22 00:00:00

<= 2012-07-04 23:59:59

Although I tend to find it just generally easier to bump the date and not care about that 1 second where there might be a false positive:


<= 2012-07-05

posted by mattsah 7 years ago

Or you could just do < and not equal to th next day and leave off the time info which woul avoid the 1 second.

posted by mattsah 7 years ago

thanks for clearing that out to me.

posted by netpork 7 years ago