Results 1 to 4 of 4
  1. #1
    rayted is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2016
    Posts
    34

    How to retrieve results by date which has date and time in the field

    Hi guys,

    I am trying to run a query to return results within the past i.e. date()-1 etc.

    However, the source has this format: 28/04/2017 17:00:09. The source is from a linked table (pulling emails from a folder on outlook)

    Therefore, the query is returning no results. How do I get around this?



    Thank you

  2. #2
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,931
    date formats are irrelevant - in the underlying value, dates are stored as decimal numbers, the bit before the dp represents the date counting up from 31/12/1899 as 0 so today is 43217. The bit after the dp represents the time as the time in seconds divided by 86400 - the number of seconds in the day - so 8:51am=0.3680324074

    so if your field contains a time you are trying to find say 43217.3680324074 < 43218-1 - which it isn't so isn't returned.

    solution depends on what you are trying to do - either add 1 to your search date or just compare the date part of the search date

    fielddate<=date()+1-1

    or

    datevalue(fielddate)<=date()-1

  3. #3
    rayted is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2016
    Posts
    34
    Hi Ajax,

    Your suggestions do not work unfortunately. I am still not getting any results.

    Is there a way I can build the left function in to return results? Maybe using expression builder? Then I can just retrieve the first part of the date?

    Thanks!

    *UPDATE* I have got the date using the left function! should be good for now. Thanks your assistance Ajax!

  4. #4
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,931
    without knowing your code, impossible to say why it doesn't work

    as advised, be aware that date is stored as a number, not text so I would check carefully what your left function is actually returning - I suspect when you get to the 1st May, it will return 5th Jan

    good luck with your project

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

Similar Threads

  1. Replies: 6
    Last Post: 04-19-2016, 03:58 PM
  2. Replies: 11
    Last Post: 07-20-2014, 06:22 PM
  3. Replies: 2
    Last Post: 07-17-2014, 01:46 AM
  4. Subtracting a date/time field from a number to get date/time
    By Lifeseeker1019 in forum Programming
    Replies: 4
    Last Post: 03-28-2014, 12:59 PM
  5. Use DLookup to Retrieve Field Value from a Date?
    By Heatshiver in forum Programming
    Replies: 8
    Last Post: 04-06-2012, 10:09 AM

Tags for this Thread

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