Page 1 of 2 12 LastLast
Results 1 to 15 of 19
  1. #1
    aellistechsupport is offline Competent Performer
    Windows 7 32bit Access 2013
    Join Date
    Apr 2014
    Posts
    410

    Date Range Parameter - Confused

    Currently have this:
    Code:
    SELECT dbo_v030mbrshp02Collegiates.MemberType, dbo_v030mbrshp02Collegiates.MembershipNumber, dbo_v030mbrshp02Collegiates.EndYear AS Season, dbo_v030mbrshp02Collegiates.PaymentDate, dbo_v030mbrshp02Collegiates.EndDate
    FROM dbo_v030mbrshp02Collegiates
    WHERE (((dbo_v030mbrshp02Collegiates.MemberTypeID)=8))
    GROUP BY dbo_v030mbrshp02Collegiates.MemberType, dbo_v030mbrshp02Collegiates.MembershipNumber, dbo_v030mbrshp02Collegiates.EndYear, dbo_v030mbrshp02Collegiates.PaymentDate, dbo_v030mbrshp02Collegiates.EndDate
    HAVING (((dbo_v030mbrshp02Collegiates.PaymentDate) Between IIf(Month(Date())<=7,DateSerial(Year(Date())-4,6,1),DateSerial(Year(Date())-3,6,1)) And IIf(Month(Date())<=7,DateSerial(Year(Date()),Month(Date()),0),DateSerial(Year(Date()),Month(Date()),0))) AND ((dbo_v030mbrshp02Collegiates.EndDate) Between IIf(Month(Date())<=7,DateSerial(Year(Date()),6,1),DateSerial(Year(Date())+3,6,1)) And IIf(Month(Date())<=7,DateSerial(Year(Date())+3,6,30),DateSerial(Year(Date())+4,6,30))))
    ORDER BY dbo_v030mbrshp02Collegiates.EndYear, dbo_v030mbrshp02Collegiates.PaymentDate, dbo_v030mbrshp02Collegiates.EndDate;
    Which is to show total of memberships where the memberships end next year and 4 years out.

    It was working until August report.
    Now it's only showing memberships ending in 2018 and 2019. It should be also be showing 2016 and 2017.

    In July when the report was ran it showed
    2015
    2016
    2017
    2018

    which is what it should do. Now that it's August it should show
    2016
    2017
    2018


    2019

    Anyone know what I have incorrect?

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    So you want to filter based on a fiscal year, not calendar year?

    What is EndYear field for? Why don't you apply filter to that field?

    Why are you using GROUP BY when there are no aggregate calcs?
    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
    aellistechsupport is offline Competent Performer
    Windows 7 32bit Access 2013
    Join Date
    Apr 2014
    Posts
    410
    EndYear is the year their membership ends

    That is what needs to show for four years.

    These particular memberships are good for 4 years.

    They want to see how many memberships ending in the current year + 4.
    Since memberships are good for 4 years the PaymenDate would go back a few years for the memberships ending this year and so on.

    Not sure why it is only showing 2018 and 2019 since the fiscal year started.
    Last month it showed all four years like it should.

    So something in the formula isn't quite right that it would show only 2 years after the new fiscal year started whereas it was showing 4 years as it should before the new fiscal year month started.

    Hope that made sense.

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    Why are you filtering on PaymentDate?

    Is EndYear the fiscal year?

    EndYear BETWEEN Year(Date()) + IIf(Month(Date())>7, 1, 0) AND Year(Date()) + IIf(Month(Date())>7, 1, 0) + 3

    Why using GROUP BY when there are no aggregate calcs?
    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.

  5. #5
    aellistechsupport is offline Competent Performer
    Windows 7 32bit Access 2013
    Join Date
    Apr 2014
    Posts
    410
    Need to limit the PaymentDate from 4 years ago as well from the start of the fiscal year 4 years ago.

    That said, PaymentDate filter is the fiscal year.

    The EndYear is only when those PAID memberships end.

    I'll try your formula, thank you.

    The Group is because the table with the data set has membership numbers and need the total for each month.

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    Is EndYear the fiscal year or calendar year? So if their membership ends in August 2015, would EndYear show 2015 or 2016?

    But there are no aggregate calcs in that query.

    Consider building a report and doing aggregate calcs in report design.
    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.

  7. #7
    aellistechsupport is offline Competent Performer
    Windows 7 32bit Access 2013
    Join Date
    Apr 2014
    Posts
    410
    Hi june7,
    sonyiur formula did produce 4 years as hoped.
    however what happens in Jan 2016?

    it says greater than July?

    thank you

    oh Report is not an option unfortunately. This is one part of 8 other parts

  8. #8
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    > July because I thought the fiscal year break is July 31.

    Don't see any issue with January 2016. If you run query on January 1 then you should get fiscal years 2016-2019, just as if you had run the query on December 31.

    The criteria filters on the EndYear value, month is irrelevant.
    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.

  9. #9
    aellistechsupport is offline Competent Performer
    Windows 7 32bit Access 2013
    Join Date
    Apr 2014
    Posts
    410
    Code:
     Month(Date())>7, 1, 0)
    I get that the 1st part is saying greater than month 7 (July), what is the 1, 0

  10. #10
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    Those are the two options the IIf() will return depending on the condition being true or false. The IIf will add either 1 or 0 to the current year to arrive and the fiscal year.

    Year(Date()) + IIf(Month(Date())>7, 1, 0)
    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.

  11. #11
    aellistechsupport is offline Competent Performer
    Windows 7 32bit Access 2013
    Join Date
    Apr 2014
    Posts
    410
    Ok I think I understand, so if it's greater than July it'll be this year (1) otherwise it'll show future year (0)?

  12. #12
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    Not quite, you have it backwards.

    If month is greater than July it will ADD 1 to the current year, otherwise ADD 0. This is to determine the fiscal year. So 8/1/2014 through 7/31/2015 will be captured as fiscal year 2015. If you prefer it to be considered fiscal year 2014, then swap the positions of 1 and 0 in the expression.
    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.

  13. #13
    aellistechsupport is offline Competent Performer
    Windows 7 32bit Access 2013
    Join Date
    Apr 2014
    Posts
    410
    Thank you so much for clarifying and your help!

  14. #14
    aellistechsupport is offline Competent Performer
    Windows 7 32bit Access 2013
    Join Date
    Apr 2014
    Posts
    410
    Hi June7,
    Is there another way to write your suggestion in SQL View?

    I tried this but getting an Invalid or missing expression:
    Code:
    BETWEEN Year(GetDate()) + IIf(Month(GetDate())>7, 1, 0) AND Year(GetDate()) + IIf(Month(GetDate())>7, 1, 0) + 3

  15. #15
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    Why are you using GetDate()? Why not Date()?
    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.

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

Similar Threads

  1. Replies: 4
    Last Post: 04-25-2015, 04:17 PM
  2. Parameter Box Date Range
    By buckwheat in forum Access
    Replies: 14
    Last Post: 10-01-2013, 07:20 AM
  3. Replies: 3
    Last Post: 09-11-2013, 09:49 AM
  4. Date Range Report with Multiple Date Fields
    By StevenCV in forum Reports
    Replies: 13
    Last Post: 02-29-2012, 08:29 AM
  5. Date Range Parameter help!?!?
    By dkstech in forum Access
    Replies: 1
    Last Post: 01-15-2011, 11:05 AM

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