Support

Search results for ""

Sorry, no results found. Perhaps you would like to search the documentation?
All Topics
Dirk

Sorting dates as text string

I understand you can’t sort and filter dates in custom fields because you don’t know what format they will be in, but how about allowing dates to be sorted just by their text value? It should work well on YYY-MMMM-DD HH:MM-SS formats.

If it is supposed to do that now, there is a bug.

6 years, 6 months ago
Stefan van den Dungen Gronovius
Developer

Hi Dirk,

Sorting on a date is indeed based on the text value, so the format Y-m-d should indeed work for both the default as the date field type. Since this is not working for you, I believe the other Custom Field column may also not work for your environment. Can you check that for me?

6 years, 6 months ago
Dirk

What do you mean by “the other Custom Field column”?

6 years, 6 months ago
Stefan van den Dungen Gronovius
Developer

Hi Dirk,

Sorry, I meant the Custom Field type (text/date).
Within the custom field column, you can select the field type.
If you set this field to text, you can sort on the column and it should be sorted based on the text value, this should work in your case. If you set the field type ‘date’ sorting is based on the numeric value. This should also work for Y-m-d formats.

Can you send me your column set up by making an export with our plugin and send it to support@admincolumns.com so I can have a look for you? And are you sure the value in the DB is Y-m-d for your custom field?

6 years, 6 months ago
Dirk

Just noticed that we had added the following code from you a few versions back. do we need to remove this?

function ac_set_meta_column_type_to_date_format( $columns ) {
foreach ( $columns as $column ) {
if ( ‘column-meta’ == $column->get_type() && ‘date’ == $column->get_field_type() ) {
$column->set_properties( ‘filterable_type’, ‘date_format’ );
}
}
}

6 years, 6 months ago
Dirk

I removed the code above and I think that fixed it.

6 years, 6 months ago
Stefan van den Dungen Gronovius
Developer

Hi Dirk,

Sorry, I did not have time to dive into this, but if it fixes the problem, then it’s great :)
Thanks for the feedback, I will close this ticket. If you still have some problems, please let me know.

6 years, 6 months ago

You must be logged in to reply to this topic.