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 7826739
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T09:33:17+00:00 2026-06-02T09:33:17+00:00

I am working on script which requires giving the admin the ability to insert

  • 0

I am working on script which requires giving the admin the ability to insert dates for when he wants a parking lot available, the admin inserts dates in a range.

I am having a hard time coming to a solution to what would be the best way to store the dates in MySQL.

Should i store the dates using two columns AVAILABLE_FROM_DATE and AVAILABLE_UNTIL_DATE?

PLID    AVAILABLE_FROM DATE         AVAILABLE_UNTIL_DATE
1       2012-04-01                  2012-04-03
1       2012-04-05                  2012-04-15
2       2012-04-21                  2012-04-30

OR should i just use a single column AVAILABLE_DATE and store the ranges the admin selects in a new row for each date between the range?

[EDIT START]
What i mean above by using a single column is not to join or split the dates into a single column, i actually mean to store a date in a single row with a single column like below:

PLID    AVAILABLE_DATE
1       2012-04-01
1       2012-04-02
1       2012-04-03

and so on for all the available dates i want to store.
[EDIT END]

Basically, the admin will want to insert a date range the parking lot is available and allow members to choose that slot if the user is looking for a slot within that range.

OR is there some better and simpler way to do this?

I am currently trying to use the first method using separate columns for the range, but having trouble getting the desired results when looking for parking lots within a range.

[EDIT START]

SELECT * FROM `parking_lot_dates`
WHERE (available_from_date BETWEEN '2012-04-22' AND '2012-04-30'
AND (available_until_date BETWEEN '2012-04-22' AND '2012-04-30'))

I use the following query on the above rows i have, and it returns empty.
I want it to return the last row having the PLID 2.
[EDIT END]

Thank you in advance.

  • 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-02T09:33:18+00:00Added an answer on June 2, 2026 at 9:33 am

    Regarding your EDIT with the query, you have the logic inside out. You need to compare whether each date you are checking is inside the range BETWEEN available_from_date and available_until_date, like this:

    SELECT * FROM `parking_lot_dates`
    WHERE
    (
            '2012-04-22' BETWEEN available_from_date AND available_until_date
        AND '2012-04-30' BETWEEN available_from_date AND available_until_date
    )
    

    Demo: http://www.sqlfiddle.com/#!2/911a3/2

    Edit: Although if you’ll want to allow partial-range matches, you’ll need both types of logic, i.e., the parking lot is available 4-22 to 4-27, and you need it 4-23 to 4-28. You can use it for the dates 4-23 to 4-27, but not 4-28.

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

Sidebar

Related Questions

i am working on script which creates events in Google Calendar from data in
I'm working with a script in which the postid of the page has been
I have the following script, which is working for the most part Link to
I'm working on a custom DotNetNuke module which requires the use of Lightbox. What's
I am working on this website which requires a jquery/ajax contact form. Everything works
I'm working on a project that requires that the vertical borders, which are currently
I am working on a PHP script which involves me including several external PHP
I'm currently working on a reminder PHP Script which will be called via Cronjob
Can a PHP script (which can be working with a MySQL DB) send and/or
I've got a little script which is not working nicely for me, hope you

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.