November 3, 2009 at 12:21 pm
Hey all,
I have been tasked with adding a table that stores all the dates for our fiscal years.
I want to add each year at a time
Our problem stems with the fact that our fiscal year starts at strange times. For instance I want to add FY 2008, the start date is 12/02/07.
Here are the things I am trying to add and the table created...
CREATE TABLE [dbo].[Calendar](
[dt] [smalldatetime] NOT NULL,
[isWeekday] [bit] NULL,
[isHoliday] [bit] NULL,
[Y] [smallint] NULL,
[FY] [smallint] NULL,
[FYQ] [tinyint] NULL,
[FYM] [tinyint] NULL,
[D] [tinyint] NULL,
[DW] [tinyint] NULL,
[monthname] [varchar](9) NULL,
[dayname] [varchar](9) NULL,
[WeekNumber] [tinyint] NULL,
PRIMARY KEY CLUSTERED
(
[dt] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
While I can get the majority of this data into the table what I am really having a hard time with is finding the fy week number, fy month number.
I need 12/02/07 to be week 1 and month 1 if that makes more sense...
Any help is greatly appreciated!
November 3, 2009 at 12:39 pm
Will DateDiff(Week) from the start date of the year give you the week?
- Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
Property of The Thread
"Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon
November 3, 2009 at 12:58 pm
Are your storing every date in the year or just start and end dates for Fiscal months and such?
I ask because the Datediff week calculation will not work correctly...
You may need to do datediff(week, date, date) + 1
Because 2007-12-02 and 2007-12-03 will return 0 because they are in the same week.
-Luke.
November 3, 2009 at 1:30 pm
What is the business rule for the beginning of a new fiscal year (always first Sunday of December?)
What is the business rule for defining a fiscal month? Is it based on week pattern (like 4-4-5-4-4-5 a.s.o.) or when does a new fiscal month start?
November 5, 2009 at 10:36 am
Hey Imu,
Thought I had this correct but seems like it is more how you have it
Here is the cunundrum.
Our fiscal year ends the Saturday after the last Friday or November, the next Fiscal year start the immediate Sunday.
If a week has wed-sat falling in the next month it is considered a new week, new month.
The business rule for defining a Fiscal Month is as you have it below
(like 4-4-5-4-4-5 a.s.o.)
November 5, 2009 at 11:54 am
marty.seed (11/5/2009)
...If a week has wed-sat falling in the next month it is considered a new week, new month.The business rule for defining a Fiscal Month is as you have it below
(like 4-4-5-4-4-5 a.s.o.)
Sounds like an either/or to me...
I'm not sure if it's possible to meet both criteria all the time (haven't tried it yet).
Could you please clarify?
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply