Problem:-
I want to show only those Documents which are before the deadline of the page.
when deadline equals or less than the currentdate then show
else move to archive or send to archive file.

How to write a code for this or a query ?
as for understanding , Picture is attached.

Code for the above mentioned problem is required if possible.
THanks,

Dani AI

Generated

Good quick answer from — two lists (current vs archive) is the simplest approach. Below are practical production tips and gotchas to make that reliable and safe for real apps.

Keep data types and timezones correct

  • Store deadlines in DATE or DATETIME (not as free text). Normalize times (UTC is easiest) and convert only for display. Use PHP DateTime for conversions and reliable comparisons (PHP DateTime manual).
  • Compare dates consistently on one side (DB or app). Mixing client time and server DB time causes subtle bugs.

Choose an archiving strategy

  • Soft-archive: add a boolean/status column (e.g., archived) and filter it out on the main page. Simple, reversible, and keeps related FK integrity.
  • Hard-archive: copy expired rows into an archive table and delete from the main table to keep queries fast. Requires transactional copy/delete and careful testing.

Operational advice for hard archive

  • Run archiving in a scheduled job (cron or MySQL Event Scheduler) during low load. Consider the MySQL event scheduler for server-side scheduling ().
  • Move rows in small batches inside a transaction to avoid long locks. Log each run and alert on failures.
  • Index the deadline column for fast range filters and avoid SELECT * in production queries to reduce IO (MySQL indexing basics).

User-facing tips

  • Show "expires in N days" for current documents so users see impending expirations.
  • Provide an archive UI and retention policy so archived items can be purged later.

This approach preserves correctness, avoids timezone traps, and scales as the table grows.

Recommended Answers

All 3 Replies

My deadline field in database is deadline and current date variable is $curdate

you can create two separate pages for say
1) current
2) archive

the difference is only in query

for current

select * from tablename where deadline>current_date()

for archive

select * from tablename where deadline<=current_date()

:
Thanks Dear.
Solved!

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.