• WrightBrain

    (@wrightbrain)


    I need to be able to search within range of dates, but the filter is consistently returning “0” results. I’ve tried as many setting as I could but with no luck.

    Currently, the field is set to “Date yyyy-mm-dd (ISO)”, the Format is set to “Date Translateable” and the filtering is set to “Date range”

    My “test” search/filter has been for 2021-10-01 to 2021-11-01. Can you help?

    The page I need help with: [log in to see the link]

Viewing 11 replies - 1 through 11 (of 11 total)
  • Plugin Author anmari

    (@anmari)

    Hi, I cannot see your page, login required.
    Please check how your field’s date is actually stored (not how you have set the field type, or how you have chosen to format it, but how the data is actually stored in the database).

    I have just re tested on both yyyy-mm-dd dates and unix dates, and it is working for both.

    See https://directories.wpusersplugin.com/alpha-nav-list/ for normal dates and
    unix dates here https://directories.wpusersplugin.com/profile-grid-user-list/.

    I did find some little bugs (field label on unix date range) and a possible failure of jquery-ui css to load because it had http not https, so I’ll be pushing an update 1.2 out for those. But otherwise the base functionality works.

    So then the next step for you would be for you to investigate your data.

    Thread Starter WrightBrain

    (@wrightbrain)

    Sorry about that. I undid the login requirement.

    I’m not sure how to check how it’s stored in the database? But I did try updating the field to read as YYYY-MM-DD. It’s still not working for me.

    Plugin Author anmari

    (@anmari)

    Use phpmyadmin and look at the wp user meta table for your fields.

    It doesn’t matter how you format the fields. In fact, right now it is probably better if you don’t format those fields at all, just so we can see their ‘raw’ form if you don’t how to look at your database. Looking at formatted list doesn’t help.

    The formatting routines are very forgiving, they will try make sense of any date format. The date range selection CANNOT be. For that the dates MUST either be in YYYY-MM-DD or unix timestamp format.

    Plugin Author anmari

    (@anmari)

    Re phpmyadmin – this is either via your hosting control panel or there are some plugins where you can run it inside wordpress or from wordpress.
    If you are maintaining your own website, it is a really good idea to have some understanding of the database and the data.

    Plugin Author anmari

    (@anmari)

    Ha! found it – I saw you had the CSV extract enabled, and that extracts raw data.

    Whatever you are using to create those date fields, appears to have them stored as dd/mm/yyyy which is very unhelpful in multiple ways, not to mention dangerous. Those are basically ‘strings’, not date fields in the DB. I suggest you see if there is a way to create true date fields as expected by MySQL https://dev.mysql.com/doc/refman/8.0/en/datetime.html and by wordpress, like the user registration field. Then any sorting and querying by less than / greater than becomes easier.

    The only reason the plugin appears to handle these is because there is php function tries a best guess based on commonly accepted formats https://www.php.net/manual/en/function.strtotime.php. Slashes are usually thought to be american with mm/dd/yyyy, however yours have 26/10/21 sp are not american.

    Thread Starter WrightBrain

    (@wrightbrain)

    Thanks, unfortunately, this does not help me at all. I’ve contacted you and support for my other plugin and I cannot get the format changed. I may just have to find another solution.

    Plugin Author anmari

    (@anmari)

    Yes it is a useless way to store dates if one is expecting to do any logic or SQL querying comparison on then.
    Good luck !

    Thread Starter WrightBrain

    (@wrightbrain)

    Well, that, and I didn’t understand the information in the links.

    Thread Starter WrightBrain

    (@wrightbrain)

    Okay, I figured out a work-around. Instead of search via date range, I switched to the text range search and used the same format that’s in the database, and that did the trick.

    Not ideal, but it gets the job done.

    Plugin Author anmari

    (@anmari)

    Apologies – I had another look and see now that I jumped to an idea of what your raw data was based on looking at your csv in excel, not in csv. And excel had switched the format – classic mistake.

    I should have waited for you to figure out how to look at your raw data.

    I was correct however in that the addon currently only caters for ISO (International Standards Organisation) date time YYYY-MM-DD and unix timestamps.

    The raw data does have year first which is why the text range works for it. The problem with using the jquery datepicker date string, is probably that in searching with the date picker for everything between say 2021-08-dd and 2021-09-dd, one is not going to find the records with 2021/08/dd.

    I’ll have a look at how best to cater for this and see if I can add it in, convert the datepicker format to whatever people say their date format is (so long as years are first ?? )

    Thread Starter WrightBrain

    (@wrightbrain)

    Thank you for taking a second look, I really appreciate that. I noticed that excel did convert the dates too, which does muddy the waters a bit. That’s also probably why I struggled to change the format so much. (I think, I don’t really know.)

    At any rate, I’ll look for the update, but in the meantime, the easiest way for someone on a Mac to see the raw, unconverted data is to preview it in TextEdit instead of Numbers or Excel which will automatically do some formatting.

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Date Range Filter Not Working’ is closed to new replies.