Results 1 to 8 of 8
  1. #1
    diegomarino is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Feb 2018
    Posts
    434

    date join +/- a week

    hi, i have this query
    Code:
    SELECT SpeseBuffer.Persona, SpeseBuffer.[Tipo di spesa], SpeseBuffer.Data, SpeseBuffer.Pertinenza, SpeseBuffer.Note, SpeseBuffer.Importo, Spese.Persona, Spese.DataFROM SpeseBuffer LEFT JOIN Spese ON (SpeseBuffer.Data = Spese.Data) AND (SpeseBuffer.Persona = Spese.Persona) AND (SpeseBuffer.Importo = Spese.Importo)
    WHERE (((SpeseBuffer.Data)>#5/1/2020#) AND ((SpeseBuffer.Pertinenza)="COmuni") AND ((Spese.Data) Is Null));
    the join i have highlighted is the part i want to modify: since i use this query to update a "expenses" table from and excel made by the bank site, i have the issue that some dates are not precisely the same (when i use my card the date of operation is different from the date they really take my money from my account).


    so, since some values are added manually in the past, the dates are not the same for a few days.

    May i change the join making something "spesebuffer.data +/- 10 days"?

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,646
    I have seen imprecise join with text fields using LIKE operator. I doubt can do with dates. Maybe should fix the data?
    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.

  3. #3
    diegomarino is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Feb 2018
    Posts
    434
    i dont think so, they are old records and not so few.
    maybe i'ėll run a routine using recordset.
    when i find the solution i'll post here

  4. #4
    diegomarino is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Feb 2018
    Posts
    434
    a solution could be converting date in text and then extract just month/year, but (even if possible and i really don't know now) a month is a toog big time interval
    maybe using the week value?

  5. #5
    Micron is offline Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,372
    In my experience, the date of purchase can be 1 or several days earlier than the posted transaction, so I don't see how any arbitrary number of days will help. You could use a subquery to get a posted date by using something like TOP 1 where posted date > than purchase date and date is ordered by descending. However, without something to tie in the purchase (like a vendor) you could retrieve any purchase where the posted date was greater than the purchase date and it won't necessarily be the same vendor.

    I think responders would need to see a good chunk of data (doesn't have to be your real data) in order to provide more focused help. You could paste an edited spreadsheet as a table in a post.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  6. #6
    diegomarino is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Feb 2018
    Posts
    434
    hi
    those are my two tables, my bank movements are just that, i have to insert in shared expenses (with my wife) all records that have no corrispondence (we started in 2018 so the dates before must be not considered)
    i really do not mind vendors in this case, i want just to add bank movements that have no corrispondence in shared expenses and have "pertinenza" field = "Comuni", so the import is fine as join, the problem is the date as we said.

    i like the subquery idea but no clue about what it it
    i use a buffer table to insert my bank movement records in the same shape of shared expenses table, dunno if necessary
    Attached Files Attached Files

  7. #7
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,845
    you can use a non standard join (only doable in the sql view), so instead of

    (SpeseBuffer.Data = Spese.Data)

    you would have


    (SpeseBuffer.Data <= Spese.Data+10 AND SpeseBuffer.Data >= Spese.Data-10)

    or take it out of the join and put it in the criteria

    in both cases leave the other joins and criteria as is



  8. #8
    diegomarino is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Feb 2018
    Posts
    434
    this one i meant! so it's possible

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

Similar Threads

  1. Convert Date to Day of the Week
    By hikerdood in forum Access
    Replies: 4
    Last Post: 04-01-2019, 02:18 PM
  2. Replies: 10
    Last Post: 01-23-2016, 12:29 PM
  3. Replies: 9
    Last Post: 06-19-2015, 03:37 PM
  4. Replies: 3
    Last Post: 01-21-2015, 02:40 PM
  5. Replies: 3
    Last Post: 04-01-2012, 01:40 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