On Tue, Mar 31, 2009 at 2:17 PM, Zefram <[email protected]> wrote:
> Terrence Brannon wrote:
>>Intuitively, it would seem that specifying the 'before' of a datetime
>>span using the end option of the ->from_datetimes() constructor would
>>yield a range that is 1 second (1 nanosecond?) earlier than the actual
>>date supplied.
>
> I would not find that intuitive. Your 1 second or 1 nanosecond would
> be a completely arbitrary mutation of the supplied data.
Yes, I would determine that aribtrary 1 second or nanosecond based on
the data in my database tables. a MySQL BETWEEN clause includes its
endpoints.
If I want all data for a certain date, my BETWEEN clause must be from
00:00::00 to 23:59:59 assuming a datetime column.
Using the start and end dates supplied by Datetime::Span would lead to
overlapping SQL query results on successive days, hence the following
module:
use DateTime::Span::Common;
# ideal for DATETIME columns
my $x = DateTime::Span::Common->new(shave => [seconds => 1]);
# not sure what this would be practical for
my $y = DateTime::Span::Common->new(shave => [nanoseconds => 1]);
my @dto = $x->today;
@dto = $x->yesterday;
@dto = $x->this_week;
@dto = $x->last_week;
@dto = $x->this_month;
@dto = $x->last_month;
@dto = $x->year_to_date;
@dto = $x->last_year;
my $sth = $dbh->prepare('SELECT * FROM table WHERE order_date
BETWEEN ? AND ?');
$sth->execute(@dto);