Comparing Time Periods or Date Ranges with SQL
TL;DR
SELECT * FROM periods
WHERE range_start <= @check_period_end
AND range_end >= @check_period_startThe opposite:
| { | |
| "$schema": "https://getcomposer.org/schema.json", | |
| "name": "laravel/laravel", | |
| "type": "project", | |
| "description": "The skeleton application for the Laravel framework.", | |
| "keywords": ["laravel", "framework"], | |
| "license": "MIT", | |
| "require": { | |
| "php": "^8.2", | |
| "laravel/framework": "^11.31", |
| <?php | |
| declare(strict_types=1); | |
| namespace App\Providers; | |
| use Illuminate\Database\Eloquent\Model; | |
| use Illuminate\Support\Facades\DB; | |
| use Illuminate\Support\Facades\URL; | |
| use Illuminate\Support\Facades\Vite; |
| <template> | |
| <div class="date-picker"> | |
| Month: <input type="number" ref="monthPicker" :value="value.month" @input="updateDate()"/> | |
| Year: <input type="number" ref="yearPicker" :value="value.year" @input="updateDate()"/> | |
| </div> | |
| </template> | |
| <script> | |
| export default { | |
| props: ['value'], |
Comparing Time Periods or Date Ranges with SQL
TL;DR
SELECT * FROM periods
WHERE range_start <= @check_period_end
AND range_end >= @check_period_startThe opposite:
| /** @var \Illuminate\Log\Writer $log */ | |
| $log = App::make('log'); | |
| DB::listen(function ($sql, $bindings, $time) use ($log) { | |
| if ( ! starts_with($sql, 'select')) | |
| return; | |
| // only log long running select statements | |
| if ($time <= 1) |