Date as Parameter - Between 4/1 and 4/18 doesn't inlclude 4/18records

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • sara

    Date as Parameter - Between 4/1 and 4/18 doesn't inlclude 4/18records

    Hi -
    I have had this problem MANY times and I just don't think I have the
    best solution.

    I am running a parameter query to retrieve records where work was
    completed between 2 dates. The "completed date" field contains both
    date and time (e.g., 11/4/07 15:44:00) and does need the time for the
    data to be properly recorded.

    That said, is it possible to format the parameter "Between [Enter
    start date] and [Enter end date]" to enable the user to enter just the
    dates when prompted rather than the date and time to retrieve all
    records betwen the dates?

    Currently, to retrieve records completed between 4/1/08 and 4/18/08 by
    entering dates only, the user must enter 4/19/08 to retrieve a record
    that was completed some time during 4/18/08.

    I tried adding a field to the query:
    JustDate: DateValue([CallDateAndTime]) with
    Between [Start date] and [End Date]

    and tried
    Between DateValue([Start date] and Datevalue([End Date])

    Got errors - couldn't run code - too complex...

    I can do it if I say between [End date] +1, but there MUST be a
    "proper" way!

    Thanks
    sara
  • Rich P

    #2
    Re: Date as Parameter - Between 4/1 and 4/18 doesn't inlclude 4/18 records

    Hi Sara,

    Instead of using Between try this:

    Dim RS As DAO.RecordSet
    Set RS = CurrentDB.OpenR ecordset("Selec t * From ... Where Date1 >= #" &
    txtStartDate & "# And Date2 <= #" & txtEndDate & "#")

    And then retrieve whatever data you need from the recordset object

    Or if you are using a parameter Query try this:

    In the StartDate field enter this:
    >=Forms!yourFor m!txtStartDate

    in the EndDate field enter this:

    <=Forms!yourFor m!txtEndDate

    Rich

    *** Sent via Developersdex http://www.developersdex.com ***

    Comment

    • paii, Ron

      #3
      Re: Date as Parameter - Between 4/1 and 4/18 doesn't inlclude 4/18 records


      "sara" <saraqpost@yaho o.comwrote in message
      news:632b0fd3-6afd-4028-ba58-b4b45c5fc34a@u6 9g2000hse.googl egroups.com...
      Hi -
      I have had this problem MANY times and I just don't think I have the
      best solution.
      >
      I am running a parameter query to retrieve records where work was
      completed between 2 dates. The "completed date" field contains both
      date and time (e.g., 11/4/07 15:44:00) and does need the time for the
      data to be properly recorded.
      >
      That said, is it possible to format the parameter "Between [Enter
      start date] and [Enter end date]" to enable the user to enter just the
      dates when prompted rather than the date and time to retrieve all
      records betwen the dates?
      >
      Currently, to retrieve records completed between 4/1/08 and 4/18/08 by
      entering dates only, the user must enter 4/19/08 to retrieve a record
      that was completed some time during 4/18/08.
      >
      I tried adding a field to the query:
      JustDate: DateValue([CallDateAndTime]) with
      Between [Start date] and [End Date]
      >
      and tried
      Between DateValue([Start date] and Datevalue([End Date])
      >
      Got errors - couldn't run code - too complex...
      >
      I can do it if I say between [End date] +1, but there MUST be a
      "proper" way!
      >
      Thanks
      sara
      Add 1 day to the entered end date. Date fields with time included are
      greater than dates without time.

      Between [Start Date] And DateAdd("d",1,[End Date])


      Comment

      • Chuck

        #4
        Re: Date as Parameter - Between 4/1 and 4/18 doesn't inlclude 4/18 records

        On Thu, 17 Apr 2008 12:59:31 -0700 (PDT), sara <saraqpost@yaho o.comwrote:
        >Hi -
        >I have had this problem MANY times and I just don't think I have the
        >best solution.
        >
        >I am running a parameter query to retrieve records where work was
        >completed between 2 dates. The "completed date" field contains both
        >date and time (e.g., 11/4/07 15:44:00) and does need the time for the
        >data to be properly recorded.
        >
        >That said, is it possible to format the parameter "Between [Enter
        >start date] and [Enter end date]" to enable the user to enter just the
        >dates when prompted rather than the date and time to retrieve all
        >records betwen the dates?
        >
        >Currently, to retrieve records completed between 4/1/08 and 4/18/08 by
        >entering dates only, the user must enter 4/19/08 to retrieve a record
        >that was completed some time during 4/18/08.
        >
        >I tried adding a field to the query:
        >JustDate: DateValue([CallDateAndTime]) with
        >Between [Start date] and [End Date]
        >
        >and tried
        >Between DateValue([Start date] and Datevalue([End Date])
        >
        >Got errors - couldn't run code - too complex...
        >
        >I can do it if I say between [End date] +1, but there MUST be a
        >"proper" way!
        >
        >Thanks
        >sara
        What does "between" mean in Access? The help file is not very helpful.
        However, reading between the lines suggests that between means "greater than or
        equal to " and "less than" (>= and <). That means that in Access, 'between'
        means including first value but not including last value.

        From a dictionary: "Thus in the sentence The bomb landed between the houses,
        the houses are seen as points that define the boundaries of the area of impact
        (so that we presume that none of the individual houses was hit)." To me this
        is and <.


        Comment

        • sara

          #5
          Re: Date as Parameter - Between 4/1 and 4/18 doesn't inlclude 4/18records

          On Apr 17, 4:11 pm, Rich P <rpng...@aol.co mwrote:
          Hi Sara,
          >
          Instead of using Between try this:
          >
          Dim RS As DAO.RecordSet
          Set RS = CurrentDB.OpenR ecordset("Selec t * From ... Where Date1 >= #" &
          txtStartDate & "# And Date2 <= #" & txtEndDate & "#")
          >
          And then retrieve whatever data you need from the recordset object
          >
          Or if you are using a parameter Query try this:
          >
          In the StartDate field enter this:
          >
          =Forms!yourForm !txtStartDate
          >
          in the EndDate field enter this:
          >
          <=Forms!yourFor m!txtEndDate
          >
          Rich
          >
          *** Sent via Developersdexht tp://www.developersd ex.com***
          Thanks very much. I was thinking that it could be done without the >=
          or whatever, but I understand it can't. I'm all set.

          Comment

          • sara

            #6
            Re: Date as Parameter - Between 4/1 and 4/18 doesn't inlclude 4/18records

            On Apr 17, 4:28 pm, "paii, Ron" <n...@no.comwro te:
            "sara" <saraqp...@yaho o.comwrote in message
            >
            news:632b0fd3-6afd-4028-ba58-b4b45c5fc34a@u6 9g2000hse.googl egroups.com...
            >
            >
            >
            >
            >
            Hi -
            I have had this problem MANY times and I just don't think I have the
            best solution.
            >
            I am running a parameter query to retrieve records where work was
            completed between 2 dates. The "completed date" field contains both
            date and time (e.g., 11/4/07 15:44:00) and does need the time for the
            data to be properly recorded.
            >
            That said, is it possible to format the parameter "Between [Enter
            start date] and [Enter end date]" to enable the user to enter just the
            dates when prompted rather than the date and time to retrieve all
            records betwen the dates?
            >
            Currently, to retrieve records completed between 4/1/08 and 4/18/08 by
            entering dates only, the user must enter 4/19/08 to retrieve a record
            that was completed some time during 4/18/08.
            >
            I tried adding a field to the query:
            JustDate:  DateValue([CallDateAndTime]) with
            Between [Start date] and [End Date]
            >
            and tried
            Between DateValue([Start date] and Datevalue([End Date])
            >
            Got errors - couldn't run code - too complex...
            >
            I can do it if I say between [End date] +1, but there MUST be a
            "proper" way!
            >
            Thanks
            sara
            >
            Add 1 day to  the entered end date. Date fields with time included are
            greater than dates without time.
            >
            Between [Start Date] And DateAdd("d",1,[End Date])- Hide quoted text -
            >
            - Show quoted text -

            Thanks very much. I was thinking that it could be done without the >=
            or whatever, but I understand (now) it can't. I'm all set.

            Comment

            Working...