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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T21:51:57+00:00 2026-05-14T21:51:57+00:00

I have 2 databases. One is properties and the other is dates . In

  • 0

I have 2 databases. One is properties and the other is dates. In dates I have associated the land_id and a date (In YYYYMMDD format) which means that the date is not available.

I need to formulate a query that a user can specify a start and end date, and then choose a property for which dates are available (not in the date database). How do airline and hotel websites do this kind of logic? I was thinking about taking the date range and picking all days in between and doing a query where the dates do not match and ordering it by number of results, but I can see how that could easily turn into an intense query.

CREATE TABLE IF NOT EXISTS `dates` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `land_id` int(11) NOT NULL,
  `date` varchar(255) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=44 ;

--
-- Dumping data for table `dates`
--

INSERT INTO `dates` (`id`, `land_id`, `date`) VALUES
(43, 1, '20100526'),
(39, 1, '20100522'),
(40, 1, '20100523'),
(41, 1, '20100521'),
(42, 1, '20100525');
  • 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-05-14T21:51:58+00:00Added an answer on May 14, 2026 at 9:51 pm

    Having the Dates as VARCHAR will make it harder to write a query. I suggest
    to save the dates as DATE and use the following query.
    This should help:

    SELECT * FROM dates WHERE date NOT BETWEEN '<start_date>' AND '<end_date>'
    

    It selects the dates not being between the given range.

    I found a solution in the MySQL 5.1. reference in order to make it work with VARCHAR,too:

    SELECT STR_TO_DATE(date,'%Y%m%d') as real_date 
    FROM dates WHERE real_date NOT BETWEEN '<start_date>' AND '<end_date>'
    

    Or

    SELECT DATE(date) as real_date 
    FROM dates WHERE real_date NOT BETWEEN '<start_date>' AND '<end_date>'
    

    btw: <start_date> and <end_date> are placeholders. Insert the concrete dates there (in format YYYY-MM-DD).

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

Sidebar

Related Questions

In one of my Django projects that use MySQL as the database, I need
I have an entity relationship setup in my mvc2 application such that each user
I have an application which contains multiple state machine instances when running. I would
I have a web service app that has an xml file with Oracle connection
Let's say I have a class Voucher: public class Voucher { public Guid Id
I have a requirement to implement contact database. This contact database is special in
I want to lazy load of @Lob properties. First ,i use javassist to instrument
I am creating a tool with which to edit web pages within a CMS.
I have a legacy database with 3 tables like this: (source: bilder-hochladen.net ) The
Assuming I have some data in the form of Customer1 Name Address Order1 ID

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.