• Resolved Steven

    (@shyzer)


    Hey Tobias, quick question. How do you sort by date using mm/dd/yyyy?

    I have a test page with an example of my table. If I sort by date, it starts using the month instead of the year.

    I looked through the Extensions, but none of them seemed to address this. Apologies if I overlooked it.

    Thanks!

Viewing 13 replies - 1 through 13 (of 13 total)
  • Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    thanks for your question, and sorry for the trouble.

    I’m not sure why the date sorting is not working here out of the box (as it should) but we can try to force it. For that, please add this to the “Custom Commands” text field on the table’s “Edit” screen:

    "columnDefs": [ { "type": "date", "targets": [ 3 ] } ]
    

    Regards,
    Tobias

    Thread Starter Steven

    (@shyzer)

    Tobias, you are the freaking best! That custom command forced the dates to sort exactly as I wanted.

    Just so I understand, what is the 3 referencing in the custom command?

    Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    no problem, you are very welcome! ?? Good to hear that this helped!

    The 3 is referring to the fourth column of the table (which has the dates, in your table). As counting starts with 0 in this code, column 4 is indicated by that 3.

    Best wishes,
    Tobias

    Thread Starter Steven

    (@shyzer)

    Ahh, that makes perfect sense. Thanks again!

    Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    sure! Always happy to help!

    Best wishes,
    Tobias

    Hey Tobias, i have an similar Problem here. When u need the Website we have to gp in a privat chat, because ist just a dev site for now.
    I created a table with 3 columns, Date | Description | Another text.
    In the first column is the date in european format dd.mm.yyyy
    Now i install your additional addon Datatables and fill custom commands with:
    “columnDefs”: [ { “type”: “date”, “targets”: [ 0 ] } ]
    Do i have to add an special command for european/german date ?
    Because presently it isnt working.

    Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    thanks for your post, and sorry for the trouble.

    To use the German/European format, you’ll just need a small change now:

    "columnDefs": [ { "type": "date-eu", "targets": [ 0 ] } ]
    

    Regards,
    Tobias

    Works fine!
    Thanks a lot Tobias.
    Perhaps put it in ur FAQ or example, i searched ur whole site for it ??

    Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    no problem, you are very welcome! ?? Good to hear that this helped!

    Yes, I should probably add this to the Extensions’ web page.

    Best wishes,
    Tobias

    P.S.: In case you haven’t, please rate TablePress here in the plugin directory. Thanks!

    Hi Tobias,

    Can I jump in here with a similar query? Firstly, my date format is yyyy-mm-dd, and so far ‘date’ and ‘date-eu’ haven’t worked for me:

    “columnDefs”: [ { “type”: “date-eu”, “targets”: [ 2 ] } ]
    “columnDefs”: [ { “type”: “date”, “targets”: [ 2 ] } ]

    My dates are in column 3. I had a quick google reagrding my date format, and it looks like I’m using the Danish standard?! I’m guessing I need to use the suffix for this part of the world, but I don’t know what that is in your extension!

    Awesome plugin by the way ??

    Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    thanks for your post, and sorry for the trouble.

    The format yyyy-mm-dd could actually work out of the box. And actually, we might not even need a date sorting algorithm, but can sort this as text strings – which actually is the default already…
    Can you please post a link to the page with the table where this problem happens (without any of the “Custom Commands” from above), so that I can take a direct look? Thanks!

    Regards,
    Tobias

    Hi Tobias – ha, no need at all to apologise, thanks for your speedy response! Is there a way I can share the link privately?

    Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    could you send it by email then? The address is in the main plugin file “tablepress.php”.

    Regards,
    Tobias

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘Sort by Date Method?’ is closed to new replies.