Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Quick MySQL date question

  • 08-11-2006 03:34PM
    #1
    Closed Accounts Posts: 2,175 ✭✭✭


    I'm using phpmyadmin.

    I have an 'expires' field in one of my tables. So I'd like to set the default to be something like current date + 4 months, or thereabouts. Is there a way to do it in phpmyadmin?

    Thanks.


Comments

  • Closed Accounts Posts: 119 ✭✭frodo_dcu


    unfortunatly as far as i know you can't set the default value in mysql to be function so you would have to do this in your php script when add the row


  • Closed Accounts Posts: 2,175 ✭✭✭chamlis


    I figured as much tbh.

    I just wonder if there is an in-built one of somesort somewhere in phpmyadmin.

    Thanks frodo.
    Can anyone confirm this?


  • Registered Users, Registered Users 2 Posts: 2,206 ✭✭✭Serbian


    I don't think it can be done by default alright, but you can make it pretty easy by doing it in your SQL statement when adding a row:
    INSERT INTO table (some_field, expires) VALUES ('some_field_value', DATE_ADD(NOW(), INTERVAL 4 MONTH))
    


Advertisement