Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8574689
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T19:31:48+00:00 2026-06-11T19:31:48+00:00

I have to store a different number of values in a column called, date_of,

  • 0

I have to store a different number of values in a column called, date_of, for the date of an event. There can be multiple dates that it takes place, for instance Oct 1st, 2nd, and 6th. And I need to store that in that column as three different dates. Now I do this like this:

1350619200, 1350705600, 1350792000

So what I want to be able to do is order the mysql result by the date(s). The first date should be the one that it gets ordered by, however if there are multiple dates as shown above, if the date is pass then it should go to the second date, then third date etc.

I’m not sure how to get started with this, my main priority is to just order the results by the first date in the array, the other part of my question isn’t as important.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T19:31:49+00:00Added an answer on June 11, 2026 at 7:31 pm

    If you order by the first field, which is always set, then you can try extracting the field:

    ORDER BY SUBSTRING_INDEX(date_of, ',', 1);
    

    Actually, you could order by date_of, since lexicographic order is maintained. You’d be in trouble if you wanted to order by the last subfield, but since you want the first…

    Now “if the first element of the date is past” is a bit tricky.

    ORDER BY CASE WHEN SUBSTRING_INDEX(date_of, ',', 1) > UNIX_TIMESTAMP()
        THEN SUBSTRING_INDEX(date_of, ',', 1)
        ELSE ... END
    

    could be a start, but then if there is no second subfield? If we iterate SUBSTRING_INDEX, we get again the first field.

    You would have to iterate the CASE itself. Shudder

    ORDER BY CASE WHEN SUBSTRING_INDEX(date_of, ',', 1) > UNIX_TIMESTAMP()
        THEN SUBSTRING_INDEX(date_of, ',', 1)
        ELSE
            CASE WHEN SUBSTRING_INDEX(SUBSTRING_INDEX(date_of, ',', 2),',',-1) > UNIX_TIMESTAMP()
            THEN SUBSTRING_INDEX(SUBSTRING_INDEX(date_of, ',', 2),',',-1)
            ELSE
                CASE WHEN SUBSTRING_INDEX(SUBSTRING_INDEX(date_of, ',', 3),',',-1) > UNIX_TIMESTAMP()
                THEN SUBSTRING_INDEX(SUBSTRING_INDEX(date_of, ',', 3),',',-1)
                ELSE 999999999
                END
            END
        END
    

    I can see there’s no great performances to be had from this structure. I would strongly advise for having the three dates in three different columns, or the model reengineered to have dates in a separate table.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have multiple classes that will store similar data for different uses and I
I have used localStorage[key] and key being different strings to store my values while
How can I store arrays in single array? e.g. I have four different arrays,
I have a Magento store which needs different prices for each site, which restricts
I have two tables which are used to store details of different types of
I have one postgresql table where I store some stories from different sites. At
I have a DB that stores different types of tasks and more items in
I have a stored procedure that does, among other stuff, some inserts in different
Suppose I have a search screen that is intended for looking up items. There
I have a MySQL table, with the field ('ad_id'). I store variables in different

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.