Wrox Programmer Forums
|
SQL Server 2000 General discussion of Microsoft SQL Server -- for topics that don't fit in one of the more specific SQL Server forums. version 2000 only. There's a new forum for SQL Server 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2000 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 4th, 2004, 04:26 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 625
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to jemacc
Default Fiscal Year

Hi all,

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

[u]Part One</u>
1-If the current month >= 10 add 1 year as nextyear
2-If the current month <= 10 subtract 1 year lastYear
[u]Part two</u>
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

Jaime E. Maccou
Applications Analyst
mailto:jemacc@earthlink.net

"Our lives begin to end the day we become silent about things that matter."

- Dr. Martin Luther King, Jr.

"The mind does not take its complexion from the skin..."

- Frederick Douglass

There is always a way to do it better . . . find it!" Thomas A. Edison
__________________
Jaime E. Maccou
 
Old October 4th, 2004, 10:30 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 141
Thanks: 1
Thanked 0 Times in 0 Posts
Default

First all, at the following statement, you are trying to get the Month

select @begMonth=datepart(yy,getdate())

It needs to be -- select @begMonth=datepart(mm,getdate())

I will take a look at your code in detail tomorrow.




 
Old October 6th, 2004, 02:05 AM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 625
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to jemacc
Default

Hi all,

I received some assistance

Here is part of the statement

Create procedure dbo.FiscalYear
AS
Set NOCOUNT On
declare @MonthDate datetime,@FiscalYear char(30)
set @monthDate=getdate()
set @Fiscalyear='FiscalMonth'+'fiscalyear'
select datename(m,@monthDate)as FiscalMonth,
right(datename(yy,dateadd(yy,case when month(@monthDate)>=10
then 1 else -1 end,@MonthDate)),2) as FiscalYear



Jaime E. Maccou
Applications Analyst
 
Old October 6th, 2004, 09:59 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

Just to cleanup.:)
Quote:
quote:Create procedure dbo.FiscalYear
AS
Set NOCOUNT On
declare @MonthDate datetime--,@FiscalYear char(30)
set @monthDate=getdate()
--set @Fiscalyear='FiscalMonth'+'fiscalyear'
select datename(m,@monthDate)as FiscalMonth,
right(datename(yy,dateadd(yy,case when month(@monthDate)>=10
then 1 else -1 end,@MonthDate)),2) as FiscalYear
Are the ones marked in GREEN in use? Hope it can be removed.

_________________________
- Vijay G
Strive for Perfection
 
Old October 7th, 2004, 03:05 AM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 625
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to jemacc
Default

The ones marked in green are not needed, thank you for pointing it out.

Jaime E. Maccou
Applications Analyst





Similar Threads
Thread Thread Starter Forum Replies Last Post
To get current year darshil XSLT 3 May 21st, 2007 06:46 AM
Year format Tachyophan Access 4 May 24th, 2006 06:34 AM
Date= starting of the current fiscal year rmanu7382 Reporting Services 0 April 3rd, 2006 12:42 AM
How to calculate "last year"? ihsail Linux 1 December 1st, 2005 06:03 PM
Year Validation jputhra SQL Server 2000 1 December 10th, 2004 10:03 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.