Query Access Via Date Ranges

Ask a Question related to Coldfusion Database Access, Design and Development.

  1. #1

    Default Query Access Via Date Ranges

    Hey, crew... Just trying to figure out the best way to perform queries based on
    certain date ranges

    Example:

    Let's say I want to pull all records that meet this criteria within 0-3months.
    Should I create a variable to hold the current date and then do comparisons to
    that? I would assume so, but don't know the correct syntax.

    If anyone can help, it would be greatly appreciated.

    Code Attached:

    <cfquery name="getLeads" datasource="momlink">
    SELECT Cust.FirstName, Cust.LastName, Cust.Odr_Date, Cust.Orderrec,
    Cms.Order_st2
    FROM Cust, Cms
    WHERE Cust.Orderrec = Cms.Order
    AND Cms.Ord_Total gt 0
    AND Cms.Ord_Total <= 100
    AND Cms.Sales_ID = '#UCase(GetAuthUser())#'
    AND **WITHIN DATE RANGE**
    </cfquery>

    Natesac Guest

  2. Similar Questions and Discussions

    1. Verity collection date ranges
      I have a collection of documents differentiated by topic and date. The search result looks something like this, "/Supply/Supply2004/23Jan06". I...
    2. MS Access + date query
      Hi I have got access table with two date/time field namely field1 and field2. I made one html form that inputs two dates (it's not mandatory...
    3. Searching with Date Ranges
      If I want to show events (records in a MySQL table) for the next 10 days (and I do), what would be the best approach to searching with this range? ...
    4. [PHP] Searching with Date Ranges
      Seth Willits wrote: SELECT * FROM Table WHERE event_date BETWEEN NOW() AND NOW() + INTERVAL 10 DAY; You quote yourself in your own...
    5. Date Ranges Reservations Bookings Rentals
      Hi Schoffio, There is a great room reservation program created by CobaltSky that he posted on another forum. I have used the exact same...
  3. #2

    Default Re: Query Access Via Date Ranges

    Do a lookup on DateDIff. That would allow you to compare dates in SQL.
    Abinidi Guest

  4. #3

    Default Re: Query Access Via Date Ranges

    SQL has a between expression. So you could calculate your start and end dates
    in CF w/ DateDiff, then use them in the query

    SELECT Cust.FirstName, Cust.LastName, Cust.Odr_Date, Cust.Orderrec,
    Cms.Order_st2
    FROM Cust, Cms
    WHERE Cust.Orderrec = Cms.Order
    AND Cms.Ord_Total gt 0
    AND Cms.Ord_Total <= 100
    AND Cms.Sales_ID = '#UCase(GetAuthUser())#'
    AND Cust.Odr_Date BETWEEN #calculatedStartDate# and #calculatedEndDate#

    steveInCO Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139