[Plugin: custom tables] Filter by date field
-
Im hawing a table where one value is a date field.
How is the correct syntax if I want to filter and display only
dates that are same or bigger as today?thanks for help.
-
To be more clear what Im trying to do.
Filter the display of values to be like this SQL:
SELECT * FROMwp_wct5WHERE datum>=NOW()but can’t find the example how to do this in this plugin.
Hi
Use time()
SELECT * FROM wp_wct5 WHERE datum >= 'time()'But:
SELECT * FROM wp_wct5 WHERE datum >= 'time()'can return some dates not, because of the time within the date when its been stored. Therefor its possible that you need to use
SELECT * FROM wp_wct5 WHERE datum >= 'time()-1d'that the correct entries are displayed. Try it.
I’m probably doing something really stupid…
I’m putting this in my page:
[wctable id="5" filter="SELECT * FROM wp_wct5 WHERE datum >= 'time()-1d'"]result none (WP3.3)
This one will work:
[wctable id="5" filter="datum >= 'time()-1d'"]2.6.0 will have cronjob functionality (Premium Feature), where you can automatically set all entries to passive which are older then last day…
great info & it’s working many thanks
just one more tiny question.
wctselect isn’t supporting filters?[wctselect id="5" field="razred" maintext="Razred" filter="datum >= 'time()-1d'"]no and yes.
You DONT need to add filter=”” and no, this is not supported.
BUT, if you have a filter on the table, the filter is automatically set by the wctselect (Bugfix in v2.6.0 added).
So, add the filter on the table and dont care about, will added automatically in the select.
it’s some how not working in my case:
[wctselect id="5" field="razred" maintext="Razred"] [wctselect id="5" field="nadomesca" maintext="Nadomešča" ] [wctable id="5" filter="datum >= 'time()-1d'"]Im Using WrodPress V3.3 and custom tables V2.6.0
I thing the WP3.3 is the problem because when I do
custom tables -> table name -> view setup -> table setup
it seems that those red and blue buttons (table,link,kategory…) are gone :/confirmed v3.3 bug 🙁
They have changed the impelemtation of the Visual editor, need to change that.
I did a fix for it, hope it runs well. Please report back!!
Yes & No
The custom tables -> table name -> view setup -> table setup those red and blue buttons (table,link,kategory…) are back and working 🙂
but the [wctselec … isn’t
it shows all values & (counts) but the table is today empty (all dates are older)
hm.. error in the filter?
If the filter has an error, no items will be displayed and no wntries are in wctselect. Thats normal.
Can you send me the shortcode including the filter which you have added?
Or there are no entries within the db which are newer.
Please check.In the page I have only
[wctselect id="5" field="razred" maintext="Razred"] [wctselect id="5" field="nadomesca" maintext="Nadomešča" ] [wctable id="5" filter="datum >= 'time()-1d'"]the fields “razred” and “nadomesca” are type varchar(32)
the field datum is type datethe filter on table works so in this moment the table displays empty. this is correct because all entry in field “datum” are older than today.
but both the wctselect drop downs contain all the values of the table (if the filter would apply they shouldn’t display anything like the wctable)
Yes, thats correct.
If you add the wctselects to the headerline, you will not need to add a filter. If you add them directly on the page (as you do) there is no way right now to filter.
I will add there the filter also for the next version.
Otherwise if you have premium, you can enable the cronjob for the date as
UPDATE wp_wct5 SET status=’passive’ WHERE date <= ‘time()’;and you dont need the filter on the table or wctselect.
Or as sad, wait on next version (I added it already on the development version right now).Regards
The topic ‘[Plugin: custom tables] Filter by date field’ is closed to new replies.