change value of one element between certain dates

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • tolkienarda
    Contributor
    • Dec 2006
    • 316

    change value of one element between certain dates

    hi all

    i have a table that keeps track of classes or a small school, the class becomes inactive after a certain date, this date is stored in my table, is there any way to change the value of my active element after the date specified in my EndDate element.

    thanks
    eric
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    Originally posted by tolkienarda
    hi all

    i have a table that keeps track of classes or a small school, the class becomes inactive after a certain date, this date is stored in my table, is there any way to change the value of my active element after the date specified in my EndDate element.

    thanks
    eric
    Depends on what processes are run when the record was inactivated. Generally you should be able to reactivate the record. Did you try it and it gave you an error?
    Maybe I'm misunderstandin g your question ...

    Comment

    • tolkienarda
      Contributor
      • Dec 2006
      • 316

      #3
      my knowledge of sql and sql logic is very limited, i have not any complex database applications before. so that is why my question is probably not as clear as it could be. but here is a more detailed explanation of what i have.

      i have a table with an ID, Class, Active, EndDate rows. i never want to permanently delete any of these records just make them inactive by setting the Active element of that record to 0, i would like this to be done automatically after the date stored in the EndDate element.

      I am programing in php on a mac server running apache, and mysql. i am not sure if i need a separate php script to run every day that just does maintenance, or if there is something built into mysql that will automatically change that elements value when i need it to.

      thanks
      eric

      Comment

      • acesfull
        New Member
        • Oct 2007
        • 2

        #4
        This looks like it would be best suited for a cron job executing the something like following:

        UPDATE YourTable SET Active=0 WHERE EndDate <= CURRENT_DATE()

        Depending on your EndDate format, this should work

        Originally posted by tolkienarda
        my knowledge of sql and sql logic is very limited, i have not any complex database applications before. so that is why my question is probably not as clear as it could be. but here is a more detailed explanation of what i have.

        i have a table with an ID, Class, Active, EndDate rows. i never want to permanently delete any of these records just make them inactive by setting the Active element of that record to 0, i would like this to be done automatically after the date stored in the EndDate element.

        I am programing in php on a mac server running apache, and mysql. i am not sure if i need a separate php script to run every day that just does maintenance, or if there is something built into mysql that will automatically change that elements value when i need it to.

        thanks
        eric

        Comment

        • tolkienarda
          Contributor
          • Dec 2006
          • 316

          #5
          Originally posted by acesfull
          This looks like it would be best suited for a cron job executing the something like following:

          UPDATE YourTable SET Active=0 WHERE EndDate <= CURRENT_DATE()

          Depending on your EndDate format, this should work
          OK thanks do i have to put this into a php script and run it every few days or is there some way to set up mysql to do that automaticaly.

          eric bressler

          Comment

          Working...