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

  • Home
  • SEARCH
  • 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 7001471
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T20:48:27+00:00 2026-05-27T20:48:27+00:00

I want to select the value between the date Table1 Code Period Datefrom dateto

  • 0

I want to select the value between the date

Table1

Code Period  Datefrom   dateto     Value
001  07/2011 01/07/2009 10/07/2009 100
211  07/2009 01/07/2009 05/07/2009 200

From the above table i want to check the date between datefrom and dateto, if the date is in between or equal to datefrom dateto means, it should return the value of the empcode

Tried Query

SELECT Value
FROM table1
Where Period = '07/2009'
and Code = '211'
and Cast('02/07/2009' as Datetime) between datefrom and dateto

Expected Output:

code value
211  200

The above query is showing null value, it should return 200.

What wrong in my query?

  • 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-27T20:48:27+00:00Added an answer on May 27, 2026 at 8:48 pm

    Your Cast('02/07/2009' as Datetime) brings to you 7th February by default
    use this instead

    SELECT Code, Value 
    FROM table1 
    Where 
        Period = '07/2009' 
    and Code = '211'  
    and CONVERT(DATETIME, '02/07/2009', 103) between datefrom and dateto
    

    BUT

    You, probably have to convert datefrom and dateto columns too if they are of varchar type.

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

Sidebar

Related Questions

With Perl's WWW::Mechanize module, I want to select a random value from a select
i've got an id attribute value for an element. i want to select only
In a SELECT statement I want to convert values to strings ie. SELECT TO_STRING(value).
Basically I want to alter the boolean value selecting from the table: e.g.: SELECT
SELECT totalAmount FROM tbl BETWEEN 'date1' AND 'date2' GROUP BY DATE(date created) ORDER BY
Say I have y distinct values and I want to select x of them
I want to implement chained select boxes: the first select box determines the values
<select name="select"> </select> I want to populate the above tag with values from database.
i have users table and i have posts table i want select from users
I want to select the topmost element in a document that has a given

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.