All,
I am new to SQL, and would like to select records where the date corresponds to todays date - 1 month.
I have heard of ADD_MONTH in other platforms, but that doesn't help me out in this SQL 2000 case.
The statement that works for todays year - 1 year is:
What doesn't work for todays date - 1 month is:
This statement returns nothing, but doesn't fail.
If anyone has any ideas for this novice SQL programmer it would be appreciated.
Thanks,
bnye
I am new to SQL, and would like to select records where the date corresponds to todays date - 1 month.
I have heard of ADD_MONTH in other platforms, but that doesn't help me out in this SQL 2000 case.
The statement that works for todays year - 1 year is:
Code:
SELECT SUM(premium) FROM PRODUCTION WHERE Year(Statementdate) = Year(GetDate() - 1)
What doesn't work for todays date - 1 month is:
Code:
SELECT SUM(premium) FROM PRODUCTION WHERE Year(Statementdate) = Year(GetDate()) AND Month(Statementdate) = Month(GetDate() - 1)
This statement returns nothing, but doesn't fail.
If anyone has any ideas for this novice SQL programmer it would be appreciated.
Thanks,
bnye