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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T04:45:49+00:00 2026-05-31T04:45:49+00:00

I am trying to grab orders between certain dates using the BETWEEN operator in

  • 0

I am trying to grab orders between certain dates using the BETWEEN operator in SQL.

My date formats are in dd/mm/yyyy format.

ord_fdate is the from date: Currently 01/03/2012
ord_tdate is the to date: Currently 07/03/2012

I thought this would return all orders from 01/03/2012 (including 01/03/2012) to 07/03/2012 (including 07/03/2012).

However, it does not get orders with dates 07/03/2012

My query below; i have also included the debug output of the query;

<cfset ord_fdate = DateFormat(ord_fdate, "dd/mm/yyyy")>
<cfset ord_tdate = DateFormat(ord_tdate, "dd/mm/yyyy")>
<cfquery name="getOrders" datasource="#application.dsn#">
SELECT 
  dbo.tbl_orders.uid_orders,
  dbo.tbl_orders.dte_order_stamp

FROM
  dbo.tbl_orders
  WHERE dbo.tbl_orders.uid_order_webid=<cfqueryparam cfsqltype="cf_sql_integer" value="#session.webid#">
  AND bit_order_archive=<cfqueryparam cfsqltype="cf_sql_bit" value="no">
  AND txt_order_status=<cfqueryparam cfsqltype="cf_sql_varchar" value="Awaiting Dispatch">
  AND dte_order_stamp BETWEEN <cfqueryparam cfsqltype="cf_sql_date" value="#createODBCDate(ord_fdate)#"> AND <cfqueryparam cfsqltype="cf_sql_date" value="#createODBCDate(ord_tdate)#">
  ORDER BY dte_order_stamp DESC
</cfquery>

Debug;

WHERE (dbo.tbl_orders.uid_order_webid=?
  AND bit_order_archive=?
  AND txt_order_status=?
  AND dte_order_stamp BETWEEN ? AND ?)


  ORDER BY dte_order_stamp DESC
Query Parameter Value(s) -
Parameter #1(cf_sql_integer) = 1
Parameter #2(cf_sql_bit) = NO
Parameter #3(cf_sql_varchar) = Awaiting Dispatch
Parameter #4(cf_sql_date) = {ts '2012-03-01 00:00:00'}
Parameter #5(cf_sql_date) = {ts '2012-03-07 00:00:00'}

Not sure why it is not working.

Database is SQL 2008

Any ideas?

  • 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-31T04:45:51+00:00Added an answer on May 31, 2026 at 4:45 am

    Does your date field include time? If so, between will only give you values >= the first date, and <= the second date at midnight. Any date that includes a time past midnight will be ignored.

    I usually do something like this when dealing with dates:

    If I want everything from 1/1/2012 I set up the start date as 1/1/2012, and the end date as one day later (at midnight)…

    declare @StartDate datetime = '01/01/2012'
    declare @EndDate datetime = '01/02/2012'
    

    Then select the values like this:

    select * from your_table where date >= @StartDate and date < @EndDate
    

    When checking against the end date I want anything with a value less than the end date. This will include values such as 1/1/2012 12:30, 1/1/2012 23:20, etc.

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

Sidebar

Related Questions

Hi I am trying to grab a div from another website using JS. I
I'm trying to grab the date from my database in a standard timestamp and
I'm trying to randomly grab about 20 random rows from a table, then using
I am trying to get this SQL query to grab 1 more thing from
I'm trying to grab data from a MySQL database. Approach 2 - apply/map style
I am trying to grab stdout from a subprocess.Popen call and although I am
I'm trying to grab an arbitrary element using a CSS selector (eg. #someId .className
I'm trying to grab some JSON from Apple's iTunes JSON service. The request is
Trying to grab the two $ values and the X value from this string
im trying to grab search items from twitter via PHP curl, process and update

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.