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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T17:47:17+00:00 2026-05-22T17:47:17+00:00

I have a table with the following structure leave_id int(10) No user_id int(10) No

  • 0

I have a table with the following structure

leave_id    int(10)     No           
user_id     int(10)     No           
leavetype_id    int(15)     No           
fromdt  date    No           
todt    date    No           
no_of_days  varchar(10)     No           
status  enum('0', '1', '2', '3')    No           
modifier    varchar(35)     No           
modifiedby  varchar(25)     No           
description     varchar(100)

which contains data like this

leave_id        194
user_id     2
leavetype_id    2
fromdt          2011-04-26
todt            2011-05-09
no_of_days  9
status          3
modifier     
modifiedby   
description     some description

Now I need to search based on the leave date. For eg I want to see the leaves a user taken f( for eg user_id = 2) between 2011-04-27 and 2011-05-08. As you can see, as per the result posted above the user_id 2 was on leave from 2011-04-26 to 2011-05-09. And the given date 2011-04-27 and 2011-05-08 comes between that.

I have tried the following things

  • Between AND
  • Less than Greater than
  • 1 1 Answer
  • 3 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-22T17:47:18+00:00Added an answer on May 22, 2026 at 5:47 pm

    The following will show any leave that has at least 1 day in common with the period between '2011-04-27' and '2011-05-08' :

    SELECT *
    FROM yourtable
    WHERE fromdt <= '2011-05-08'
      AND todt >= '2011-04-27' 
    

    This will show the leaves that spanned the whole period '2011-04-27' to '2011-05-08' :

    SELECT *
    FROM yourtable
    WHERE fromdt <= '2011-04-27' 
      AND todt >= '2011-05-08' 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table with the following structure: id int(11), name varchar(250) I have
I have following table structure: CREATE TABLE pilot_groups ( id INT PK, name VARCHAR(50),
I have the following table structure: status: TINYINT locked_by: INTEGER date: DATETIME page: TINYINT
I have a table with the following structure id(int) | col1(int) | col2(int) |
I have table the following data structure in SQL Server: ID Date Allocation 1,
I have a table with the following structure: id -int(11) event_id -int(11) photo_id -int(11)
I have a table in the following structure... ID USER_ID INTEREST 1 290 soccer
i have table with following structure, name (type: TEXT) price (type: INT) color (type:
I have a table with the following structure: Referrals ReferrerID Date_Activated ReferredID INT DateTime
I have a table with the following structure: CREATE TABLE `game_entries` ( `id` int(11)

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.