mitchell255
asked on
Counting months between two dates
MS Access 2003 QUERY
Help! I need to calculate the number of months due based on the following criteria:
[Efective] = If [DriversEffective] datepart is prior to the 16th of any given month the count that month as the first month, otherwise begin month count the following month.
[EndDate] = If [DriversTermed] is null then [EndDate] = 1st of next month, otherwise, [EndDate] = [DriversTermed]
[EndDate] minus [Effective] (in number of months)
I need this in SQL so I can put it into a query. Any help is appreciated
Help! I need to calculate the number of months due based on the following criteria:
[Efective] = If [DriversEffective] datepart is prior to the 16th of any given month the count that month as the first month, otherwise begin month count the following month.
[EndDate] = If [DriversTermed] is null then [EndDate] = 1st of next month, otherwise, [EndDate] = [DriversTermed]
[EndDate] minus [Effective] (in number of months)
I need this in SQL so I can put it into a query. Any help is appreciated
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SELECT DateAdd("m",IIf(Day(dat1)< 16,0,1),Da teSerial(Y ear(dat1), Month(dat1 ),1)) as d1, nz(dat2,dateadd("m",1,d1)) as d2, datediff("m",d1,d2)
IIF(Day([DriversEffective]
Steve