We're Moving to a New Support Platform – Starting June 1st!

We’re excited to let you know that starting June 1st, we’ll be transitioning to a new support system that will be available directly on our product websites – Amelia, wpDataTables, and Report Builder. In fact, the new support platform is already live for Amelia and wpDataTables, and we encourage you to reach out to us there.

You'll always be able to reach us through a widget in the bottom right corner of each website, where you can ask questions, report issues, or simply get assistance.

While we still do not offer live support, a new advanced, AI-powered assistant, trained on our documentation, use cases, and real conversations with our team, is there to help with basic to intermediate questions in no time.

We're doing our best to make this transition smooth and hassle-free. After June 1st, this current support website will redirect you to the new "Contact Us" pages on our product sites.

Thanks for your continued support and trust – we’re excited to bring you an even better support experience!

Okay
  Public Ticket #1355237
Limit date values
Closed

Comments

  •  5
    Jottes started the conversation

    Hi,

    is there any way I can dynamically limit the values that are accepted in a date field?

    For example, not allow any values in the future, or not allow values that are more than 10 days back from today, etc.

    Thank you

  •  1,895
    Miloš replied

    Hi Johannes,
    Thank you for your purchase.

    Unfortunately something like this is not possible with the plugin build in features at the moment and it require some code customization. We can offer you our paid customization service where you can hire one of our developers to implement this feature for you.
    If you are interested please give us detailed instructions and we can send you quote for this service.

    Best regards.

    Kind Regards, 

    Miloš Jovanović
    [email protected]

    Rate my support

    Try our FREE mapping plugin! MapSVG - easy Google maps, interactive SVG maps and floor plans, choropleth maps and much more - https://wordpress.org/plugins/mapsvg-lite-interactive-vector-maps/

    wpDataTables: FAQ | Facebook | Twitter | InstagramFront-end and back-end demo | Docs

    Amelia: FAQ | Facebook | Twitter | InstagramAmelia demo sites | Docs | Discord Community

    You can try wpDataTables add-ons before purchasing on these sandbox sites:

    Powerful Filters | Gravity Forms Integration for wpDataTables | Formidable Forms Integration for wpDataTables | Master-Detail Tables

  •  5
    Jottes replied

    Thanks, but this is not an option for us at the moment.

  •  5
    Jottes replied

    I've found a solution using MySQL triggers.

    For anyone looking for something like this, here's the code:

    Say you have a table 'table' in database 'db1' with a column 'date'.

    DROP TRIGGER IF EXISTS chk_date_upd;
    delimiter //
    use db1 //
    create trigger chk_date_upd before update on db1.table
    for each row
      begin
        -- add 2000 years if the date is added like this: 10/11/17
        if  YEAR(new.date) < 100 then
            SET new.date= DATE_ADD(new.date, INTERVAL 2000 YEAR);
        end if;
        -- refuse date which is too far in the past
        if  new.date<= DATE_ADD(CURDATE(), INTERVAL -6 MONTH) then
            SIGNAL SQLSTATE '45000' 
            SET MESSAGE_TEXT = 'Date value cannot be more than six months in the past';
        end if;
        -- refuse date which is too far in the future
        if  new.date>= DATE_ADD(CURDATE(), INTERVAL 2 MONTH) then
            SIGNAL SQLSTATE '45000' 
            SET MESSAGE_TEXT = 'Date value cannot be more than two months in the future';
        end if;
      end;
    //
    delimiter ;

    Add another trigger on insert:

    DROP TRIGGER IF EXISTS chk_date_ins;
    delimiter //
    use db1 //
    create trigger chk_date_ins before insert on db1.table
    for each row
      ...
    //
    delimiter ;

    The triggers will be called before insert/update and adjusts the date or refuse it and display the custom error message to the user.

    Ticket can be closed.