Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Calculating date ranged periods based on set rules

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2000-10-16 : 18:54:02
Natie Locke writes "Hi, thx for the help.

Very urgent help needed

I need to retrieve a result from a stored proc. The single parameter will be a year value i.e. @PeriodYear=2000

Result should be:
PeriodNumber PeriodStart PeriodEnd PeriodMonth
1 24-Dec-1999 21-Jan-2000 January
2 22-Jan-2000 21-Feb-2000 February
3 22-Feb-2000 23-Mar-2000 March
.
.
.
12 23-Nov-2000 21-Dec-2000 December

The rules are as follows:
All periods begin one day after the previous period ends.
PeriodStart may be on a Saturday.
PeriodEnd must be the 6th last *weekday*(exclude weekends) of a month. May not be a Saturday or Sunday.
PeriodNumber is equal to the month number of the PeriodMonth

I would prefer being able to create a stored proc that will return the result as shown above. i.e. 'sp_GetYearPeriods 2000' for the above result.

Thank you for your help

Natie"
   

- Advertisement -