# Database Discussions > Microsoft SQL Server 2005 >  Solve for accounting period

## twdavis

I have a table with:

calendar_id,year,ACCOUNTING_PERIOD,Begin_date,end_  date, period_name

what I want to do is take one date and get the accounting period it falls in.

each period has a begin_date and end_date

example::

period 1 is from 01/01/2010 till 01/09/2010 so if the date I wanted to solve for was 1/3/2010 then it would or we would keep looking.

Thanks

----------


## rhettss

solution below, as I understand your question.

DECLARE @one_date as SMALLDATETIME
...

SELECT ACCOUNTING_PERIOD
FROM tbl
WHERE @one_date BETWEEN begin_date AND end_date

----------

