skip to Main Content

My goal is to make a column in phpMyAdmin, which counts down the remaining days of a trial period (or something like that).

So for example when I set remainingDays to 30, I want the database to execute the query every 24 hrs

Is it possible to make something like this with only phpMyAdmin in hand, or do I have to put some code onto my website to send MySql Commands to subtract it?

Any help is greatly appreciated.

2

Answers


  1. Are you familiar with datediff()? Something like:

    select datediff(target_date, curdate()) as days_remaining
    from t;
    

    That is, you can do this in a SQL query.

    Login or Signup to reply.
  2. A better approach would be to have a startDate column compute the remaining days during query execution with something like:

    select 30-datediff(now(),startDate) from...
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search