• Hi, I’m trying to make a small addon to this plugin, I want to use it with a 3 column table to display 3 events days. I was wondering if there’s a way to query the next event day starting from a specified date. Let’s look at this exemple: we have an 1 day event on 2013.11.17 and another one on 2013.12.02 if the first column of the table shows the first event day (2013.11.17) is there a way to retriev the next day with events (2013.12.02)? but if the event on 2013.11.17 would be a 3 days event then the query should return 2013.11.18 .
    Hope I’ve made myself clear. Have a nice one.

    https://www.ads-software.com/extend/plugins/event-organiser/

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Stephen Harris

    (@stephenharris)

    Hi jnhghy,

    There isn’t a function provided for this so you’ll need to use SQL.

    If the event is recurring on each of the 3 days then that would be fairly easy. If its a single event spanning 3 days, then its a bit more tricky since the database only contains the date/times of the occurrences of events, not the days on which an event exists. Should still be possible though.

    … In the second case a work-around would be to query the first event which ends after 2013.11.17: in your example, its the same event (which ends at the end of the 19th: a 3 day event). Then take its start date (17th). Then the next ‘event day’ is somewhere between 17th-19th (inclusive). Simply loop through the days to find the date after the one we started with (17th), and you end up with the 18th.

    If the original event only lasted the one day and the next event ran from 2013.12.02-2013.12.04 (for example). We would know the next ‘event day’ is between 2nd-4th (December). The earliest date after the one we started with (17th Nov) in this case would be the 2nd.

    Thread Starter jnhghy

    (@jnhghy)

    Thanks for your time.
    I’ve tried what you said and hit an issue:
    If there is a long lasting event (1 month) and some intermediar events (2-3 days events) querying for the closest start and end dates will not do the trick. An example of what I’m saying here: img
    Looking at some code examples I’ve seen the “ondate” argument for query-ing events. Do you know how does that one work? can it be splited out from the query and be made a verification on it? so I can loop 3 – n days and just check if date has events.
    Thanks

    Plugin Author Stephen Harris

    (@stephenharris)

    mmm… yeah didn’t think about that…

    The ‘ondate’ works by querying events which are active during that time-frame. E.g. if ondate is to ‘2013-01’ it will query events that start before (and including) Janurary 31st and after (and including) Janurary 1st (2013).

    Similarly with ondate set to ‘2013-01-14’ or ‘2013’ (date and year respectively). But you’re not querying events here, you’re querying dates.

    As a correction to the above you could query events which end after the current date, and sort by start date (which is default).

    Otherwise, I think you may have to go down the SQL route. (this might be helpful: https://stackoverflow.com/questions/1378593/get-a-list-of-dates-between-two-dates-using-a-function).

    Plugin Author Stephen Harris

    (@stephenharris)

    Keep in mind that the relative date queries are inclusive.

    Thread Starter jnhghy

    (@jnhghy)

    I had a look at the thread on stackoverflow but at this point I’m thinking to save each event day (if an events tarts on 3rd and ends on 7th then save 3,4,5,6,7) as post/event meta this way I’d be able to get all the posts that have an exact date as post_meta (doable using wp_Query) I think this wouldn’t be very healthy for the database but with such a request and using wordpress I’m thinking it’s normal for the database to suffer… will coded it tommorow and let you know how it looks, in the mean time if you have any advice … feel free to share it (espacially if you think this is not a good idea.)
    Regards

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Get next date with events’ is closed to new replies.