Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Financial Month Expand / Collapse
Author
Message
Posted Tuesday, February 15, 2011 8:15 PM


SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Thursday, May 22, 2014 8:28 AM
Points: 89, Visits: 159
Comments posted to this topic are about the item Financial Month

Thanks & Regards,
Kartik M Kumar..
Post #1064693
Posted Tuesday, February 15, 2011 11:54 PM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Thursday, June 19, 2014 3:41 AM
Points: 215, Visits: 174
Please provide details
Post #1064739
Posted Wednesday, February 16, 2011 12:12 PM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Monday, June 16, 2014 9:38 AM
Points: 2,163, Visits: 2,189
Am I missing something, or is the UDF code missing from the post?
Post #1065206
Posted Wednesday, February 16, 2011 11:58 PM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Thursday, June 19, 2014 3:41 AM
Points: 215, Visits: 174
Yes, the UDF code missing from the post, please update ...
Post #1065454
Posted Thursday, February 17, 2011 3:17 AM


SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Thursday, May 22, 2014 8:28 AM
Points: 89, Visits: 159
Hi All,

I donno how the UDF code was missed while publishing, I update the code as a new article, however I'm providing the same here also..

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[Fn_FinMonth]') and xtype in (N'FN', N'IF', N'TF'))
drop function [dbo].[Fn_FinMonth]
go
Create Function dbo.Fn_FinMonth(@MonthCode varchar(2))
Returns Varchar(2)
As
/*------------------------------------------------------------------------------------------------------------------------------------------
** SQLVersion : SQL 2000
** Function : Fn_FinMonth
** Author : Kartik M
** DateTime : 29 January 2011 22:30
** Version : 1.2
** Purpose : To get the financial month from the respective calander month
** ToCheck :
** Changes : KM - 06 Feburary 2011 - Change the return type form Numeric to Varchar and add Leading Zeros to avoid problem while sorting
------------------------------------------------------------------------------------------------------------------------------------------*/
/*
-- Start of Debugging Stuff
Declare @MonthCode varchar(2)
Set @MonthCode = '02' -- Pass the Month Number as Input
-- End of Debugging Stuff
*/
Begin
Declare @FinMonthC Varchar(2)
Declare @IMonthCode int

Set @IMonthCode = cast(@MonthCode as int)
if @ImonthCode between 4 and 12
Begin
Set @FinMonthC = @IMonthCode-3
Set @FinMonthC = Replicate('0', 2-len(@FinMonthC))+@FinMonthC
End

Else if @ImonthCode between 1 and 3
Begin
Set @FinMonthC = @IMonthCode+9
Set @FinMonthC = Replicate('0', 2-len(@FinMonthC))+@FinMonthC
End

Return @FinMonthC
End
--Select dbo.Fn_FinMonth ('05')
go



Thanks & Regards,
Kartik M Kumar..
Post #1065533
Posted Friday, February 18, 2011 6:57 PM


SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Thursday, May 22, 2014 8:28 AM
Points: 89, Visits: 159
Please refer above code...

Thanks & Regards,
Kartik M Kumar..
Post #1066734
Posted Saturday, March 12, 2011 10:34 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Friday, July 18, 2014 3:07 AM
Points: 1, Visits: 129
Following is simple query for the same.

DECLARE @Cal_Month AS INT
SET @Cal_Month = 1
SELECT @Cal_Month Cal_Month,ISNULL(NULLIF((@Cal_Month+9)%12,0),12) Fin_Month

SET @Cal_Month = 3
SELECT @Cal_Month Cal_Month,ISNULL(NULLIF((@Cal_Month+9)%12,0),12) Fin_Month

SET @Cal_Month = 4
SELECT @Cal_Month Cal_Month,ISNULL(NULLIF((@Cal_Month+9)%12,0),12) Fin_Month

SET @Cal_Month = 12
SELECT @Cal_Month Cal_Month,ISNULL(NULLIF((@Cal_Month+9)%12,0),12) Fin_Month
Post #1077411
Posted Friday, April 8, 2011 3:35 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Monday, April 14, 2014 8:58 PM
Points: 2, Visits: 90
Thanks for posting this, I was just about to write something similar when I came across your post.

There is one small thing that I wanted to mention: In the United States, companies have the option of selecting their own fiscal year. For example, my companies fiscal year is October 1st to September 30th of the following year.

The only proviso is that a company may not change their fiscal year without informing the regulatory authorities (IRS, SEC, etc).

So, I'm going to adapt your code to my companies fiscal year and call it good. Thanks!
Post #1090978
Posted Wednesday, April 27, 2011 5:25 AM
Right there with Babe

Right there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with Babe

Group: General Forum Members
Last Login: Today @ 5:38 AM
Points: 790, Visits: 644




DECLARE @Varmonth CHAR(2)
SELECT @Varmonth = 04

select @Varmonth =datediff(mm,'1899/04/01',DATEADD(mm,CAST(@Varmonth AS INT) ,0))%12 +CASE WHEN CAST(@Varmonth AS INT) = 3 THEN 12 ELSE 0 END

select @Varmonth = REPLICATE('0',2-LEN(@Varmonth))+@Varmonth

select @Varmonth







Regards,
Mitesh OSwal
+918698619998
Post #1099328
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse