I am trying to put together an equation that will specify the correct interval based on ‘getdate()’(today’s date). For any give date you should have a maximum of two records returned one for EOM billing and one for MID(mid month) billing. Here is and example of the tables I am using:
Startdate EndDate Interval Label
5/15/2004 6/14/2004 45298 MIDJune2004
6/1/2004 6/30/2004 45467 EOMJune2004
6/15/2004 7/14/2004 45299 MIDJuly2004
7/1/2004 7/31/2004 45468 EOMJuly2004
7/15/2004 8/14/2004 45300 MIDAug2004
8/1/2004 8/31/2004 45469 EOMAug2004
8/15/2004 9/14/2004 45301 MIDSept2004
9/1/2004 9/30/2004 45470 EOMSep2004
For example on todays date the intervals chosen should be: 45299,MIDJuly2004 and 45468,EOMJuly2004.
This is the Equation I am using but it does not work correctly when you insert other possible dates.
select Dateinterval, Label, Startdate, Enddate
from Intervals
where
getdate() >= enddate
AND
getdate() between startdate and enddate + 31
Any ideas?
Startdate EndDate Interval Label
5/15/2004 6/14/2004 45298 MIDJune2004
6/1/2004 6/30/2004 45467 EOMJune2004
6/15/2004 7/14/2004 45299 MIDJuly2004
7/1/2004 7/31/2004 45468 EOMJuly2004
7/15/2004 8/14/2004 45300 MIDAug2004
8/1/2004 8/31/2004 45469 EOMAug2004
8/15/2004 9/14/2004 45301 MIDSept2004
9/1/2004 9/30/2004 45470 EOMSep2004
For example on todays date the intervals chosen should be: 45299,MIDJuly2004 and 45468,EOMJuly2004.
This is the Equation I am using but it does not work correctly when you insert other possible dates.
select Dateinterval, Label, Startdate, Enddate
from Intervals
where
getdate() >= enddate
AND
getdate() between startdate and enddate + 31
Any ideas?