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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T15:33:42+00:00 2026-06-18T15:33:42+00:00

In sql, i write a select statement for find the dates. i am here

  • 0

enter image description hereIn sql, i write a select statement for find the dates. i am here including the time also my select statement like this….

                  select * from test where           
(
(
(DATEDIFF (day,@dat1,req_frmdate)=0 or DATEDIFF (day,@dat2,req_todate)=0)
and
(DATEDIFF (HOUR,@dat1,req_frmdate)=0 or DATEDIFF (HOUR,@dat2,req_todate)=0)
and 
(DATEDIFF (MINUTE,@dat1,req_frmdate)=0 or DATEDIFF (MINUTE,@dat2,req_todate)=0)
)       
or
  (
( @dat1 between req_frmdate and req_todate) or
( @dat2 between req_frmdate and req_todate) or
(req_frmdate between @dat1 and @dat2) or
( req_todate between @dat1 and @dat2)
)       
        )

but when i pass the date some time it not considering the time.
is this query is right? when i am passing date for example @date1=’2013-02-20 09:00′
and @date2= ‘2013-02-20 12:00′ but there is no record in my databse on this date and time
there is a record in my database at req_frmdate=’2013-02-20 13:00’ and req_todate= ‘2013-02-20 16:00’

in the screen shot of my table, i have that record in my table, when i pass the two dates
like @date1=’2013-02-20 9:00′ and @date2=’2013-02-20 12:00′ the record is coming in my select statement, it should not come the date is different that is the 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-06-18T15:33:43+00:00Added an answer on June 18, 2026 at 3:33 pm

    Assuming you want that the records will display only IF both REQ_FRMDATE and REQ_TODATE will be between your two parameter’s dates, then you can use BETWEEN Clause:

    DECLARE @dat1 DATETIME SET @dat1 ='2013-02-20 09:00.000'
    DECLARE @dat2 DATETIME SET @dat2 ='2013-02-20 12:00.000'
    SELECT * 
    FROM test 
    WHERE
       (req_frmdate BETWEEN @dat1 AND @dat2)
       AND (req_todate BETWEEN @dat1 AND @dat2)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to write an SQL statement like below: select * from tbl where
When I write an SQL statement, I usually write it like this SELECT COUNT(*)
There is sql statement select distinct create_date from articles Is it possibele to write
Can I write the T-SQL like below select * FROM (select * from TableA
Trying to find the best way to write this SQL statement. I have a
I need to write the following SQL statement in LINQ lambdas : SELECT *
In Oracle PL/SQL I was used to write: SELECT * FROM MY_TABLE WHERE ROWNUM
how do i write the following sql query in Lambda expression. select rating from
I have a perplexing SQL select statement (ugly) that I'm trying to write in
I'm trying to write a simple winforms application that executes a SQL SELECT statement

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.