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
 Transact-SQL (2000)
 Fiscal Year

Author  Topic 

jemacc
Starting Member

42 Posts

Posted - 2004-10-04 : 17:26:22
Hi all,

I am try to get the fiscal year based on the current date. I have specified my current fiscal month.

Part One
1-If the current month >= 10 add 1 year as nextyear
2-If the current month <= 10 subtract 1 year lastYear
Part two
When the #1 statement is true then the results set should be
"This year" -"NextYear" =last 2 digits are a string

When the #2 statement is true then the results set should be
"This year" -"LastYear" =last 2 digits are a string

any help will be greatly appreciated. Getting the results from part one is most important to me. Here is what I have so far

create PROCEDURE dbo.FiscalYear AS
Set NOCOUNT On
declare @MonDate char(5),@begMonth char(2),@year char(4)
select @begMonth=datepart(yy,getdate())
set @begMonth = isNull(@begMonth,1)
if len(rtrim(@begMonth)) = 1
begin
set @begMonth = '10' + rtrim(@begMonth)
end
if @begmonth >='10'
set @Year= datepart(yy,getdate()+1)
if @begmonth <'10'
set @year = datepart(yy,getdate()-1)
set @MonDate = @begMonth --+ '-01'
select @MonDate as FiscalMonth,@year as FiscalYear

jen
Master Smack Fu Yak Hacker

4110 Posts

Posted - 2004-10-05 : 00:01:14
i think i read a similar post just last week, search the forum, and from what i remember, there was a definitive answer.
Go to Top of Page

VIG
Yak Posting Veteran

86 Posts

Posted - 2004-10-05 : 01:04:47
[code]select datename(m,getdate()) FiscalMonth,
right(datename(yy,dateadd(yy,case when month(getdate())>=10 then 1 else -1 end,getdate())),2) FiscalYear[/code]
Go to Top of Page

jemacc
Starting Member

42 Posts

Posted - 2004-10-06 : 02:31:25
Thank you very much
Go to Top of Page
   

- Advertisement -