Results 1 to 4 of 4
  1. #1
    snipe's Avatar
    snipe is offline Competent Performer
    Windows 7 64bit Access 2003
    Join Date
    Sep 2013
    Posts
    287

    Using a "between" date range where the table is filled with dates populated by "Now()"

    Hey guys,

    When a user uses the entry from to input records, a [DateAdded] field is automatically added with Now() so I can get a date/time of when the record was added.

    I have a few reports that use [DateAdded]. For instance, I have a report where the user inputs a date range into a form and a report is ran off that date range that shows how many records were entered.



    If I input a few records and then run the date range, any record that was entered today doesn't get counted. I recently changed the [DateAdded] from a date only to a date/time. Now that it is switched, that report (along with a few others) don't pull any records for today.

    Any idea how to fix this?

    Thanks!

  2. #2
    NTC is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    Nov 2009
    Posts
    2,392
    In the most general terms: if the query criteria is 1 element - then for records to be returned it must exactly match that element. So in the case of Now() it must be identical down to the second.

    But if it is 2 elements (i.e. between) such as >= X and <= Y then you get a range to match against and it is much more forgiving.

    So you skin the cat either by aligning everything to not have time and be date only where you can have 1 element searches - or - you set up 2 element ranges to corral the entire time range of a date...

    Depending on whether or not you can control or change data that is already in the database may dictate your approach....

  3. #3
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    Create fields in query with expression that extracts the date part and apply filter criteria to that constructed field.

    CDate(Format([datefield], "mm/dd/yyyy")) AS DateOnly


    DoCmd.OpenReport "report name", , , "DateOnly BETWEEN #" & Me.tbxStart & "# AND #" & Me.tbxEnd & "#"
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  4. #4
    snipe's Avatar
    snipe is offline Competent Performer
    Windows 7 64bit Access 2003
    Join Date
    Sep 2013
    Posts
    287
    Got it. Thanks you two. Appreciate it as always.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 3
    Last Post: 12-06-2014, 03:59 AM
  2. Replies: 11
    Last Post: 05-09-2014, 12:00 PM
  3. Replies: 2
    Last Post: 11-26-2012, 11:12 PM
  4. Replies: 2
    Last Post: 11-14-2012, 04:47 PM
  5. Replies: 2
    Last Post: 09-29-2012, 11:22 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums