SpottyBlue 0 Junior Poster in Training

Hi,

I do need help with my solo project called Salary Expenses project in PHP and Laravel and I don't see any data for the current month in the Monthly Expenses page, even the data is recorded during the current matching month.

Can help?

My project file:

Dani AI

Generated

— short checklist and fixes for “no current-month data” issues (common causes: timezone, wrong filter, wrong column, caching).

First checks (direct DB / SQL):

  • Confirm rows actually have timestamps inside the current month range. Example (MySQL, dynamic month):

    SELECT id, amount, created_at
    FROM expenses
    WHERE created_at >= DATE_FORMAT(NOW(), '%Y-%m-01')
      AND created_at < DATE_ADD(DATE_FORMAT(NOW(), '%Y-%m-01'), INTERVAL 1 MONTH)
    ORDER BY created_at DESC;

Laravel/Eloquent recommended filters (avoid fragile string comparisons):

$start = now()->startOfMonth();
$end   = now()->endOfMonth();
$rows  = \App\Models\Expense::whereBetween('created_at', [$start, $end])->get();

Or:

$rows = \App\Models\Expense::whereMonth('created_at', now()->month)
    ->whereYear('created_at', now()->year)
    ->get();

Timezone and column-type notes (very common root cause)

  • Check PHP/Laravel timezone (config/app.php -> timezone) and php.ini date.timezone. If app time differs from DB time, a record can fall into the previous/next month.

  • MySQL: TIMESTAMP values may be converted by server/session time_zone; DATETIME is stored "as is". Verify DB timezones with:

    SELECT @@global.time_zone, @@session.time_zone;

Other things to verify

  • Make sure the query filters the correct column (created_at vs a user-entered date or a nullable month field).
  • If the page aggregates months, confirm the GROUP BY/LEFT JOIN logic isn't excluding the target month.
  • Clear Laravel caches: php artisan cache:clear, php artisan config:clear, php artisan view:clear.

Typical fix: use a datetime range (whereBetween with startOfMonth/endOfMonth) and ensure app + DB timezones match.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.