Page 1 of 2 12 LastLast
Results 1 to 15 of 26
  1. #1
    AircrewX is offline Novice
    Windows 11 Office 365
    Join Date
    Aug 2024
    Posts
    13

    Coming due date within 45 days

    ok so i have been searching for about 8 days and cant quite get this to work for me.

    I am trying to run a query that shows items in my database that are coming due within 45 days of a due date.

    I tried using this criteria: <Date()+"45" And >Date()


    Click image for larger version. 

Name:	due date.png 
Views:	19 
Size:	5.2 KB 
ID:	52153

    I thought i had it working, but then wound that it wasn't can anyone help please?
    Last edited by AircrewX; 08-27-2024 at 06:56 AM.

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    Try

    Between Date() And Date() + 45
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    AircrewX is offline Novice
    Windows 11 Office 365
    Join Date
    Aug 2024
    Posts
    13
    No joy, just zero results, but there are plenty due within 45 days.

    Thank you

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    Your image didn't come through, they have to be attached, not pasted into the reply area. What is the data type of the field? Can you attach the db here?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,556
    You do not put 45 within quotes.
    It is numeric, not a string.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  6. #6
    ano is offline Competent Performer
    Windows 11 Office 365
    Join Date
    Nov 2023
    Posts
    204
    are u sure the field is a date? and not a formatted date

  7. #7
    AircrewX is offline Novice
    Windows 11 Office 365
    Join Date
    Aug 2024
    Posts
    13
    Picture attached

    Attachment 52154

  8. #8
    AircrewX is offline Novice
    Windows 11 Office 365
    Join Date
    Aug 2024
    Posts
    13
    Sorry i cannot post table as the data is proprietary

  9. #9
    AircrewX is offline Novice
    Windows 11 Office 365
    Join Date
    Aug 2024
    Posts
    13
    Quote Originally Posted by ano View Post
    are u sure the field is a date? and not a formatted date
    Its a Short Text Field

  10. #10
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,556
    Quote Originally Posted by AircrewX View Post
    Its a Short Text Field
    Firstly DO NOT STORE DATES as text.
    Now you can try CDate() and see if that will work for you.

    Best to fix the issue at source though.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  11. #11
    ano is offline Competent Performer
    Windows 11 Office 365
    Join Date
    Nov 2023
    Posts
    204
    hope ur date in text field is mm/dd/yyyy or mmm/dd/yyyy else u have to change it to that unless it is yyyy/mm/dd

  12. #12
    AircrewX is offline Novice
    Windows 11 Office 365
    Join Date
    Aug 2024
    Posts
    13
    Quote Originally Posted by Welshgasman View Post
    Firstly DO NOT STORE DATES as text.
    Now you can try CDate() and see if that will work for you.

    Best to fix the issue at source though.
    This appears to have fixed my mistake thank you!

    Changed field from text to Date and
    Code:
    <Date()+"45" And >Date()
    works perfect now.

    Thank you guys sorry for the silly question.

  13. #13
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,556
    Well it shouldn't as you are still adding a string.

    OK it does, but do not rely on Access being so forgiving, so get used to using strings where strings should go and the same for numerics, else you will come to grief.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  14. #14
    AircrewX is offline Novice
    Windows 11 Office 365
    Join Date
    Aug 2024
    Posts
    13
    I do have a question in addition to this guys, how do i make sure the query includes the current month?

    <Date()+30 And >Date()

    Thank you

  15. #15
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,932
    can you clarify what you mean -provide an example

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 5
    Last Post: 06-06-2024, 10:33 AM
  2. Replies: 1
    Last Post: 04-29-2016, 04:03 AM
  3. Parameter coming up for expiry date
    By FranCorona in forum Queries
    Replies: 2
    Last Post: 08-09-2013, 09:59 AM
  4. Replies: 1
    Last Post: 02-12-2013, 03:48 AM
  5. Replies: 2
    Last Post: 04-27-2010, 01:25 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