Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > SQL Server > SQL Server 2000 > SQL Server 2000
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old October 4th, 2004, 04:26 PM
Friend of Wrox
 
Join Date: Nov 2003
Location: Lehigh Acres, FL, USA.
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
Reply With Quote
  #2 (permalink)  
Old October 4th, 2004, 10:30 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: , NY, USA.
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.




Reply With Quote
  #3 (permalink)  
Old October 6th, 2004, 02:05 AM
Friend of Wrox
 
Join Date: Nov 2003
Location: Lehigh Acres, FL, USA.
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
Reply With Quote
  #4 (permalink)  
Old October 6th, 2004, 09:59 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: Bangalore, KA, India.
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
Reply With Quote
  #5 (permalink)  
Old October 7th, 2004, 03:05 AM
Friend of Wrox
 
Join Date: Nov 2003
Location: Lehigh Acres, FL, USA.
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
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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 05:03 PM
Year Validation jputhra SQL Server 2000 1 December 10th, 2004 09:03 AM



All times are GMT -4. The time now is 03:27 PM.


Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.