dbTalk Databases Forums  

Fiscal Year Help

comp.databases.ms-sqlserver comp.databases.ms-sqlserver


Discuss Fiscal Year Help in the comp.databases.ms-sqlserver forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
CK
 
Posts: n/a

Default Fiscal Year Help - 02-04-2008 , 04:16 PM






Greetings All,
I have a SQL question that maybe someone out there can help me with. Our
fiscal year starts on 01/27. I want to write a query that I can pass a date
to and it will return the week number (DATEPART("ww", someDate)) of the year
using the Fiscal Year Start Date as the base. Datepart works great except it
figures the first day of the year as 1/1. Does anyone know how I can make it
work with a first day of the year equal to the fiscal year date 01/27. Any
help would be appreciated.
TIA,
~ck



Reply With Quote
  #2  
Old   
David Portas
 
Posts: n/a

Default Re: Fiscal Year Help - 02-04-2008 , 04:27 PM






"CK" <c_kettenbach (AT) hotmail (DOT) com> wrote

Quote:
Greetings All,
I have a SQL question that maybe someone out there can help me with. Our
fiscal year starts on 01/27. I want to write a query that I can pass a
date to and it will return the week number (DATEPART("ww", someDate)) of
the year using the Fiscal Year Start Date as the base. Datepart works
great except it figures the first day of the year as 1/1. Does anyone know
how I can make it work with a first day of the year equal to the fiscal
year date 01/27. Any help would be appreciated.
TIA,
~ck

Use a calendar table:

SELECT WeekNo
FROM Calendar
WHERE Dt = '20080204';

--
David Portas




Reply With Quote
  #3  
Old   
Plamen Ratchev
 
Posts: n/a

Default Re: Fiscal Year Help - 02-04-2008 , 04:31 PM



You can use a calendar table. One example here:

http://sqlserver2000.databases.aspfa...dar-table.html

You can pre-calculate your week number (just mark the Fiscal Year Start Date
week as 1 and then increase every 7 days), then querying will be very
simple.

HTH,

Plamen Ratchev
http://www.SQLStudio.com


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.