• You're right.

    If an extract is requested for the date range 2016-09-01 through 2016-09-30 ON 2016-10-01, the data will have 2016 as the [Acct Year] and will end up in the Prior Year file. Which is probably not the way to go.

    (I say probably because I'm not certain what our affiliate will want)

    If the date range of 2016-10-01 through 2016-10-31 is requested on 2016-11-01,data will flow correctly to the CurrYr file.

    The table being extracted does not currently have a transaction date column(not specified by affiliate). But I can add one and not extract it to the flat file.

    So then I could compare the [Acct Year) to DATEPART("yyyy",[GLDate])

    when they are equal and the DATEPART("mm",[GLDate] <10, output to the CurrYr file

    But, when I run a date range of 2015-09-01 through 2015-09-30 today(2016-04-22), I'll have Acct Year = 2015 and DATEPART("yyyy",[GLDate]) will be 2015 and that data will end up in the CurrYr file too, and it should go to the PriorYr file.

    I'll need to work through the logic some more next week (another issue is demanding my attention right now).

    To be continued....