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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T05:04:18+00:00 2026-05-11T05:04:18+00:00

According to cdonner , in his answer here and on his blog . He

  • 0

According to cdonner, in his answer here and on his blog.

He claims that BETWEEN with date yields inconsistent results

From his blog:

select     case when '9/1/08' between '9/1/08' and '9/15/08'         then 'in' else 'out' end as s1,     case when '9/1/08' between '8/28/08' and '9/1/08'         then 'in' else 'out' end as s2  s1   s2 ---- ---- in   in  (1 row(s) affected) select     case when '1/1/08' between '1/1/08' and '2/1/08'         then 'in' else 'out' end as s1,     case when '1/1/08' between '12/31/07' and '1/1/08'         then 'in' else 'out' end as s2  s1   s2 ---- ---- in   out  (1 row(s) affected 

Notice that the S2 answer in the second query show ‘Out’ when clearly the date should be in.

According to cdonner, the reason this is so is because:

[the] least significant digit of the DateTime type in SQL is 3 msec

I think the cause is much simpler than that. I think it’s because he’s using strings and not dates in his query.

Please excuse my SQLServer-ish. I speak mainly Oracle, so this may be ugly. But when I take his query that -proves- there’s an issue and replace his strings with datetime variables I get the correct output.

DECLARE @Jan108 datetime DECLARE @Feb108 datetime DECLARE @Dec3107 datetime  SET @Jan108 = '1/1/08' SET @Feb108 = '2/1/08' SET @Dec3107 = '12/31/07'  select     case when @Jan108 between @Jan108 and @Feb108         then 'in' else 'out' end as s1,     case when @Jan108 between @Dec3107 and @Jan108         then 'in' else 'out' end as s2 

Which is correct?

NB: this isn’t an attempt to settle an argument or to start a flame war. I truly want to understand if SQL Server BETWEEN is less functional than the Oracle BETWEEN. WE have no such issue in Oracle.

  • 1 1 Answer
  • 1 View
  • 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. 2026-05-11T05:04:19+00:00Added an answer on May 11, 2026 at 5:04 am

    In Oracle:

    select     case when '1/1/08' between '1/1/08' and '2/1/08'         then 'in' else 'out' end as s1,     case when '1/1/08' between '12/31/07' and '1/1/08'         then 'in' else 'out' end as s2 FROM dual  in out 

    You are comparing strings here, not dates.

    There is nothing BETWEEN 12/31/07 and 1/1/08, as 2 goes after / in ASCII

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

Sidebar

Related Questions

According to select name from system_privilege_map System has been granted: SELECT ANY TABLE ...and
According MSDN, FxCop is an application that analyzes managed code assemblies (code that targets
According to Hibernate documentation : After observing that arrays cannot be lazy , you
According to what I've heard, integer values that are not the processor's word size
According to the PHP Documentation PDO::prepare() adds quotes to all your parameters so that
According to this article I know, that DateTimePicker control does not reflect CurrentUICulture So,
According to C++11 9.1/7 (draft n3376) , a standard-layout class is a class that:
According to the docs: You should not override init. You are discouraged from overriding
According to this: Get current date/time in seconds var seconds = new Date().getTime() /
According to this discussion , the iphone agreement says that it doesn't allow loading

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.