casey writes "I have a table with a date field holding values
200001
200002
200003 ... to current date of 200102
YYYY MM
I'd want to write a stored procedure that selects records for the next month from the previous year:
Ex: if current date is 200101, then I want to select records from 200002.
Is it possible to use a case statement in the where clause for this?
select customer_name, Invoice_number from invoice
case
when datepart(mm,getdate()) between 1 and 11 then
where fiscal_year = (datepart(yy,getdate()) - 1)
and ( convert(int,substring(accounting_period,5,2)) + 1) = ( datepart(mm,getdate()) + 1)
else
where datepart(mm,getdate()) = 12 then
fiscal_year = datepart(yy,getdate()) and
substring(accounting_period,5,2_ = '01'
Thanks."