tags:

views:

282

answers:

2

Hi,

I want to find fiscal month and year based on a date. How Can I do it using TSQL?

I have SQl server 2008.

Any help?

Regards Manjot

+1  A: 

You should have a table defining your fiscal year, and build queries based on that. Trying to do something tricky in TSQL is only going to give you nightmares.

lod3n
+1  A: 

You store a table of days (one row per day) with date and columns for the fiscal year and month that are pertinent to your org (fiscal month and year vary from org to org).

SQL as a rule is much better at looking up data rather than computing it. A fiscal calendar table for the next century would take a puny amount of data and save tones of cycles in computation.

Remus Rusanu
Thanks for this.But if I have a date how can I find fiscal quater or month?Just add 1 for quater and add 3 for month?What about year?
Manjot
You have columns for quarter and month and any other fiscal period you're interested in, down to week (retail usually has special weeks). You never add or substract anything, just lookup a date and see what fiscal year, month, quarter it belongs to.
Remus Rusanu
Thanks very much
Manjot