Results 1 to 6 of 6
  1. #1
    jctaylor is offline Novice
    Windows 10 Access 2016
    Join Date
    Jul 2017
    Posts
    16

    Getting dates for SQL not working

    I am creating a new database program in access similar to the one I had in Visual Foxpro(it is currently still being used). I periodically update the tables with new data from the old program. I export the tables to excel and import them into Access. I have some reports based on SQL statements that get the starting and ending date using functions. I was working fine until my last data update. Now all of a sudden when I put in the beginning and ending dates, it returns no records. I have tried just putting in the dates using #date# and that doesn't work. I have checked the table and it is a date field. I must be missing something, but I don't know what. Does anybody have any ideas what could cause this to happen?

  2. #2
    Perceptus's Avatar
    Perceptus is offline Expert
    Windows 7 64bit Access 2016
    Join Date
    Nov 2012
    Location
    Knoxville, Tennessee
    Posts
    659
    Do you have the SQL code for the underlying query?

  3. #3
    jctaylor is offline Novice
    Windows 10 Access 2016
    Join Date
    Jul 2017
    Posts
    16
    SELECT ar.client, Customer.Custname, ar.ttyp, ar.inv_date, ar.inv_no, ar.inv_amt, ar.payment, ar.balance
    FROM ar INNER JOIN Customer ON ar.client = Customer.custid
    WHERE (((ar.client)>=GetBegCustId() And (ar.client)<=GetEndCustId()) AND ((ar.ttyp)="IN") AND ((ar.inv_date)>=GetBegRptDate() And (ar.inv_date)<=GetEndRptDate()))
    ORDER BY ar.inv_date;

  4. #4
    Perceptus's Avatar
    Perceptus is offline Expert
    Windows 7 64bit Access 2016
    Join Date
    Nov 2012
    Location
    Knoxville, Tennessee
    Posts
    659
    I would recommend trying the between operator. I may have the number of Parenthesis off. but I think this gives the gist.

    Code:
    SELECT ar.client, Customer.Custname, ar.ttyp, ar.inv_date, ar.inv_no, ar.inv_amt, ar.payment, ar.balance
    FROM ar INNER JOIN Customer ON ar.client = Customer.custid
    WHERE (((ar.client)>=GetBegCustId() And (ar.client)<=GetEndCustId()) AND ((ar.ttyp)="IN") AND (ar.inv_date Betweeen GetBegRptDate()  And GetEndRptDate())
    ORDER BY ar.inv_date;

  5. #5
    jctaylor is offline Novice
    Windows 10 Access 2016
    Join Date
    Jul 2017
    Posts
    16
    I tried this: SELECT ar.client, Customer.Custname, ar.inv_date, ar.ttyp, ar.inv_no, ar.inv_amt, ar.refer, ar.payment, ar.balanceFROM ar INNER JOIN Customer ON ar.client = Customer.custid
    WHERE (((ar.client)>=GetBegCustId() And (ar.client)<=GetEndCustId()) AND ((ar.inv_date) Between GetBegRptDate() And GetEndRptDate()) AND ((ar.ttyp)="IN"));

    It didn't work either.

  6. #6
    jctaylor is offline Novice
    Windows 10 Access 2016
    Join Date
    Jul 2017
    Posts
    16
    I went back and imported my data again and now it works. It must have been something wrong with the table. Thanks for your input!

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

Similar Threads

  1. Range of dates not working in vba
    By annmv888 in forum Access
    Replies: 17
    Last Post: 07-14-2016, 11:41 AM
  2. Working with multiple dates
    By k3tran in forum Access
    Replies: 1
    Last Post: 07-05-2012, 04:51 PM
  3. Sorting of dates no working?
    By Buakaw in forum Queries
    Replies: 7
    Last Post: 02-15-2012, 10:47 AM
  4. Working with departure dates
    By Dega in forum Database Design
    Replies: 5
    Last Post: 07-23-2011, 01:29 PM
  5. Working with dates
    By JerryZ in forum Queries
    Replies: 8
    Last Post: 04-03-2011, 06:23 PM

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