Title: Generated column
Last modified: May 13, 2020

---

# Generated column

 *  Resolved [larryhines](https://wordpress.org/support/users/larryhines/)
 * (@larryhines)
 * [6 years ago](https://wordpress.org/support/topic/generated-column/)
 * Can I create a generated column from the Data Designer? If so, how do I do that?
 * The context is as follows:
 * 1. I have an event with a scheduled date.
    2. I want people to register for the
   event. 3. I want the registration period restricted (Open) to a certain number
   of days before the scheduled date. 4. I know I could use the “where” feature,
   but then all events are treated the same, whereas I want to vary the registration
   period for each event(some open for 7 days; others for 30 days). 5. I have an
   integar column in the Event table that represents the days the event is open 
   before the schedule date. Then I want a generated column that calculates (populates)
   if the event is “Open/Closed”. I would then use that column in the “Where” element
   in my Projects page.

Viewing 5 replies - 1 through 5 (of 5 total)

 *  Plugin Author [Passionate Programmer Peter](https://wordpress.org/support/users/peterschulznl/)
 * (@peterschulznl)
 * [6 years ago](https://wordpress.org/support/topic/generated-column/#post-12831732)
 * Hi,
 * My first tought is to use the where clause. You can add any valid SQL where clause,
   would a sub query be an alternative?
 * How do you know the number of days for an event? Is it somewhere stored? Or calculated?
 * Best regards,
    Peter
 *  Thread Starter [larryhines](https://wordpress.org/support/users/larryhines/)
 * (@larryhines)
 * [6 years ago](https://wordpress.org/support/topic/generated-column/#post-12852155)
 * I have a column (integer) that represents the number of days prior to schedule
   date to “open” the event for registration. The value can vary (e.g. 30 days for
   some events, and 45 for others).
 * Thus the why the “where” clause would not work easily.
 * I am new to WP and SQL. It seems I could right a SQL function and run that everyday
   to update the Status column to either “Open” or “Close”. Would that work?
 *  Plugin Author [Passionate Programmer Peter](https://wordpress.org/support/users/peterschulznl/)
 * (@peterschulznl)
 * [6 years ago](https://wordpress.org/support/topic/generated-column/#post-12852304)
 * Can you share your datamodel? You can use the contactform on the plugin website
   if you prefer to send it in private.
 * Thanks,
    Peter
 *  Thread Starter [larryhines](https://wordpress.org/support/users/larryhines/)
 * (@larryhines)
 * [6 years ago](https://wordpress.org/support/topic/generated-column/#post-12861259)
 * So, I have learned some of the basic SQL syntax and can perform what I want to
   do fairly easily. My task was to update a column in a table to have an “Open”
   or “Closed” status based on the event date and the current date. I want to “Open”
   the event to registration some number of days (e.g. 45) before the actual event
   date and “Close” Registration some number of days (e.g. 7) before the actual 
   event date. I added columns to represent the open and close timeframes, and then
   used the SQL update command to update the status. Saved this as a procedure with
   a trigger to run even day.
 * I then can use the WHERE clause to filter only the OPEN events.
 * Sorry to bother you with a trivial matter.
 * Unless, of course, there is a better way. I am open to suggestions.
 * I am closing this thread.
 *  Plugin Author [Passionate Programmer Peter](https://wordpress.org/support/users/peterschulznl/)
 * (@peterschulznl)
 * [6 years ago](https://wordpress.org/support/topic/generated-column/#post-12862327)
 * Looks like you found a solution! 👍
 * I wonder, though, if you need a status and an update. If you have a start and
   end data, you should be able to select actual events and add a subquery to your
   where clause. If you want to I can have a look it, but I need to have a look 
   at your datamodel. If you’re fine with your solution, it’s okay of course.
 * Best regards,
    Peter

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Generated column’ is closed to new replies.

 * ![](https://ps.w.org/wp-data-access/assets/icon-256x256.png?rev=3299063)
 * [WP Data Access – App Builder for Tables, Forms, Charts, Maps & Dashboards](https://wordpress.org/plugins/wp-data-access/)
 * [Support Threads](https://wordpress.org/support/plugin/wp-data-access/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-data-access/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-data-access/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-data-access/reviews/)

 * 5 replies
 * 2 participants
 * Last reply from: [Passionate Programmer Peter](https://wordpress.org/support/users/peterschulznl/)
 * Last activity: [6 years ago](https://wordpress.org/support/topic/generated-column/#post-12862327)
 * Status: resolved