swares has asked for the wisdom of the Perl Monks concerning the following question:
$start_time_field='start_time'; $end_time_field='end_time'; $search = "yr-mo-dd (hr:min:sec) - yr-mo-dd (hr:min:sec) search term"; trim($search); # removes white space and non printables my $date_field_start = $public_handlers{$cmd}->{'args'}->{'date_field_ +start'}; my $date_field_end = $public_handlers{$cmd}->{'args'}->{'date_field_en +d'}; my $description_field = $public_handlers{$cmd}->{'args'}->{'descriptio +n_field'}; ($date1,$date2)=split / - /, $search; ($datetime_start) = $date1 =~ /(\d\d-\d\d-\d\d \(\d\d;\d\d:\d\d\))|(\d +\d-\d\d-\d\d)/; ($datetime_end) = $date2 =~ /(\d\d-\d\d-\d\d \(\d\d;\d\d:\d\d\))|(\d\d +-\d\d-\d\d)/; ($search_term) = $date2 =~ /\d\d-\d\d-\d\d \(\d\d;\d\d:\d\d\)(.+)|\d\d +-\d\d-\d\d (.+)/; if ($datetime_start !~ /\d\d:\d\d:\d\d/) {$datetime_start = $datetime_ +start . " 00:00:00"}; if ($datetime_end !~ /\d\d:\d\d:\d\d/) {$datetime_end = $datetime_end +. " 23:59:59"}; $query = "SELECT * FROM $table WHERE $description_field LIKE '%$search +_term%' and $start_time_field or $end_time_field between '$datetime_s +tart' and '$datetime_end' ";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Trying to select all records that match a datetime range.
by Errto (Vicar) on Apr 20, 2007 at 21:30 UTC | |
|
Re: Trying to select all records that match a datetime range.
by Zaxo (Archbishop) on Apr 20, 2007 at 22:10 UTC | |
|
Re: Trying to select all records that match a datetime range.
by roboticus (Chancellor) on Apr 21, 2007 at 03:21 UTC |