﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / SQL Server 2008 / T-SQL (SS2K8)  / Fiscal Dates / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Mon, 20 May 2013 06:10:53 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: Fiscal Dates</title><link>http://www.sqlservercentral.com/Forums/Topic1353313-392-1.aspx</link><description>These two articles might give you a method of doing what you desire.[url]http://www.sqlservercentral.com/articles/function/67046/[/url][url]http://www.sqlservercentral.com/articles/function/68323/[/url]</description><pubDate>Wed, 05 Sep 2012 18:13:47 GMT</pubDate><dc:creator>bitbucket-25253</dc:creator></item><item><title>RE: Fiscal Dates</title><link>http://www.sqlservercentral.com/Forums/Topic1353313-392-1.aspx</link><description>[quote][b]Jeff Moden (9/4/2012)[/b][hr][quote][b]RBarryYoung (9/4/2012)[/b][hr][quote][b]Jason-299789 (9/4/2012)[/b][hr][quote][b]Jeff Moden (9/3/2012)[/b][hr][quote][b]rka (9/2/2012)[/b][hr]DateKey has to be in the format YYYYMMDD[/quote]In SQL Server, that's a pretty insane requirement because that would make a character based date.  Since you're using SQL Server 2008, you should either use DATETIME or DATE datatypes for such a thing.I strongly recommmend you talk to the people that designed the table and suggest that they should probably change it.As for actually building the table... what have you tried that's not working?[/quote]Jeff I agree its pretty insane,But I've seen this especially if the YYYYMMDD is converted to an INT eg 20120101 = 20,120,101.Its been a frequent topic of discussion on various DW projects that I've worked on, prior to the Date Data type most of the calendar dims used the DateTime with the PK/SK column a CAST(CalendarDate as Int), again a pretty nasty way of doing this especially if you have a time element due to the rounding issues. However, since 2008 I've been converted to Date Data type as the PK/SK and it seems to work very well.[/quote]A "DW" is a data warehouse which is an OLAP-type database, and these rules and keys might make sense there, because an OLAP database has different goals than an OLTP database, and thus a different (though related) modelling methodology, and therefore a different set of normal rules.An OLAP database is designed to facilitate reporting, at the expense of other things, like diskspace and being able to maintain the data in real-time.  OLTP databases on the other hand are designed to facilitate real-time data updates while insuring consistency and still be able to report on the data.  Because of these differences in goals, OLAP databases will frequently have highly redundant multi-discriminating key structures, like the one you suggest, because they can greatly facilitate reporting and summarization.  But they are an anethema to an OLTP database because they introduce all kinds of problems with maintaining the consistency of the data and keys when trying to incrementally keep it up-to-date in real time.[/quote]BWAA-HAAA!!!! Is that the long version for "storing dates as INTs or VARCHARs sucks"??? :-D[/quote][b]8^Þ[/b](heh)</description><pubDate>Wed, 05 Sep 2012 17:48:02 GMT</pubDate><dc:creator>RBarryYoung</dc:creator></item><item><title>RE: Fiscal Dates</title><link>http://www.sqlservercentral.com/Forums/Topic1353313-392-1.aspx</link><description>[quote][b]RBarryYoung (9/4/2012)[/b][hr][quote][b]Jason-299789 (9/4/2012)[/b][hr][quote][b]Jeff Moden (9/3/2012)[/b][hr][quote][b]rka (9/2/2012)[/b][hr]DateKey has to be in the format YYYYMMDD[/quote]In SQL Server, that's a pretty insane requirement because that would make a character based date.  Since you're using SQL Server 2008, you should either use DATETIME or DATE datatypes for such a thing.I strongly recommmend you talk to the people that designed the table and suggest that they should probably change it.As for actually building the table... what have you tried that's not working?[/quote]Jeff I agree its pretty insane,But I've seen this especially if the YYYYMMDD is converted to an INT eg 20120101 = 20,120,101.Its been a frequent topic of discussion on various DW projects that I've worked on, prior to the Date Data type most of the calendar dims used the DateTime with the PK/SK column a CAST(CalendarDate as Int), again a pretty nasty way of doing this especially if you have a time element due to the rounding issues. However, since 2008 I've been converted to Date Data type as the PK/SK and it seems to work very well.[/quote]A "DW" is a data warehouse which is an OLAP-type database, and these rules and keys might make sense there, because an OLAP database has different goals than an OLTP database, and thus a different (though related) modelling methodology, and therefore a different set of normal rules.An OLAP database is designed to facilitate reporting, at the expense of other things, like diskspace and being able to maintain the data in real-time.  OLTP databases on the other hand are designed to facilitate real-time data updates while insuring consistency and still be able to report on the data.  Because of these differences in goals, OLAP databases will frequently have highly redundant multi-discriminating key structures, like the one you suggest, because they can greatly facilitate reporting and summarization.  But they are an anethema to an OLTP database because they introduce all kinds of problems with maintaining the consistency of the data and keys when trying to incrementally keep it up-to-date in real time.[/quote]BWAA-HAAA!!!! Is that the long version for "storing dates as INTs or VARCHARs sucks"??? :-D</description><pubDate>Tue, 04 Sep 2012 22:50:27 GMT</pubDate><dc:creator>Jeff Moden</dc:creator></item><item><title>RE: Fiscal Dates</title><link>http://www.sqlservercentral.com/Forums/Topic1353313-392-1.aspx</link><description>[quote][b]Jason-299789 (9/4/2012)[/b][hr][quote][b]Jeff Moden (9/3/2012)[/b][hr][quote][b]rka (9/2/2012)[/b][hr]DateKey has to be in the format YYYYMMDD[/quote]In SQL Server, that's a pretty insane requirement because that would make a character based date.  Since you're using SQL Server 2008, you should either use DATETIME or DATE datatypes for such a thing.I strongly recommmend you talk to the people that designed the table and suggest that they should probably change it.As for actually building the table... what have you tried that's not working?[/quote]Jeff I agree its pretty insane,But I've seen this especially if the YYYYMMDD is converted to an INT eg 20120101 = 20,120,101.Its been a frequent topic of discussion on various DW projects that I've worked on, prior to the Date Data type most of the calendar dims used the DateTime with the PK/SK column a CAST(CalendarDate as Int), again a pretty nasty way of doing this especially if you have a time element due to the rounding issues. However, since 2008 I've been converted to Date Data type as the PK/SK and it seems to work very well.[/quote]A "DW" is a data warehouse which is an OLAP-type database, and these rules and keys might make sense there, because an OLAP database has different goals than an OLTP database, and thus a different (though related) modelling methodology, and therefore a different set of normal rules.An OLAP database is designed to facilitate reporting, at the expense of other things, like diskspace and being able to maintain the data in real-time.  OLTP databases on the other hand are designed to facilitate real-time data updates while insuring consistency and still be able to report on the data.  Because of these differences in goals, OLAP databases will frequently have highly redundant multi-discriminating key structures, like the one you suggest, because they can greatly facilitate reporting and summarization.  But they are an anethema to an OLTP database because they introduce all kinds of problems with maintaining the consistency of the data and keys when trying to incrementally keep it up-to-date in real time.</description><pubDate>Tue, 04 Sep 2012 19:46:30 GMT</pubDate><dc:creator>RBarryYoung</dc:creator></item><item><title>RE: Fiscal Dates</title><link>http://www.sqlservercentral.com/Forums/Topic1353313-392-1.aspx</link><description>[quote][b]Jason-299789 (9/4/2012)[/b][hr][quote][b]Jeff Moden (9/3/2012)[/b][hr][quote][b]rka (9/2/2012)[/b][hr]DateKey has to be in the format YYYYMMDD[/quote]In SQL Server, that's a pretty insane requirement because that would make a character based date.  Since you're using SQL Server 2008, you should either use DATETIME or DATE datatypes for such a thing.I strongly recommmend you talk to the people that designed the table and suggest that they should probably change it.As for actually building the table... what have you tried that's not working?[/quote]Jeff I agree its pretty insane,But I've seen this especially if the YYYYMMDD is converted to an INT eg 20120101 = 20,120,101.Its been a frequent topic of discussion on various DW projects that I've worked on, prior to the Date Data type most of the calendar dims used the DateTime with the PK/SK column a CAST(CalendarDate as Int), again a pretty nasty way of doing this especially if you have a time element due to the rounding issues. However, since 2008 I've been converted to Date Data type as the PK/SK and it seems to work very well.[/quote]NP.  Thanks for the feedback.  I have to ask again, though... what have you tried that isn't working in your efforts to build this table?</description><pubDate>Tue, 04 Sep 2012 14:17:04 GMT</pubDate><dc:creator>Jeff Moden</dc:creator></item><item><title>RE: Fiscal Dates</title><link>http://www.sqlservercentral.com/Forums/Topic1353313-392-1.aspx</link><description>[quote] But I've seen this especially if the YYYYMMDD is converted to an INT eg 20120101 = 20,120,101. .. , since 2008 I've been converted to Date Data type as the PK/SK and it seems to work very well.[/quote] Could be worse; I have see FLOAT, GUID and weird text strings.</description><pubDate>Tue, 04 Sep 2012 13:17:34 GMT</pubDate><dc:creator>CELKO</dc:creator></item><item><title>RE: Fiscal Dates</title><link>http://www.sqlservercentral.com/Forums/Topic1353313-392-1.aspx</link><description>[quote][b]Jeff Moden (9/3/2012)[/b][hr][quote][b]rka (9/2/2012)[/b][hr]DateKey has to be in the format YYYYMMDD[/quote]In SQL Server, that's a pretty insane requirement because that would make a character based date.  Since you're using SQL Server 2008, you should either use DATETIME or DATE datatypes for such a thing.I strongly recommmend you talk to the people that designed the table and suggest that they should probably change it.As for actually building the table... what have you tried that's not working?[/quote]Jeff I agree its pretty insane,But I've seen this especially if the YYYYMMDD is converted to an INT eg 20120101 = 20,120,101.Its been a frequent topic of discussion on various DW projects that I've worked on, prior to the Date Data type most of the calendar dims used the DateTime with the PK/SK column a CAST(CalendarDate as Int), again a pretty nasty way of doing this especially if you have a time element due to the rounding issues. However, since 2008 I've been converted to Date Data type as the PK/SK and it seems to work very well.</description><pubDate>Tue, 04 Sep 2012 09:35:09 GMT</pubDate><dc:creator>Jason-299789</dc:creator></item><item><title>RE: Fiscal Dates</title><link>http://www.sqlservercentral.com/Forums/Topic1353313-392-1.aspx</link><description>&amp;gt;&amp;gt; My company wants to create a Financial Calendar Table which contains only the Fiscal Dates. &amp;lt;&amp;lt;I hope not! Fiscal calendars have to come back to the Common Era and lawful (civil) calendars. &amp;gt;&amp;gt; The requirements are populate it with the following columns:- DateKey- Fiscal_Year- Fiscal_Month- Fiscal_Week- Fiscal Week_Start_Date- Fiscal_Week_End_Date &amp;lt;&amp;lt;Again, I hope not! The idea of a “date_key” is soooo wrong so many ways. A date is a temporal unit of measurement. The attribute property “_key” is meta data in violation of ISO-11179, basic data modeling and common sense. Let me make a suggestion then explain it. CREATE TABLE Fiscal_Calendar (cal_date DATE NOT NULL PRIMARY KEY, fiscal_date CHAR(9) NOT NULL  CHECK (fiscal_date LIKE   '[12][0-9][0-9][0-9]F[0-5][0-9]-[1-7]'), etc);&amp;gt;&amp;gt; DateKey [sic] has to be in the format YYYYMMDD &amp;lt;&amp;lt;Use the calendar date. We do not care about the internal format for dates, numbers, or strings. You can use that format in the  presentations layer. But the ISO-8601 format used in SQL and the rest of the ISO Standards is 'yyyy-mm-dd', so your need a good reason to go into a local dialect. &amp;gt;&amp;gt; - Weeks begin from Monday – Sunday &amp;lt;&amp;lt;Of course, and ISO says the days are numbered 1 to 7. That is standard. &amp;gt;&amp;gt; - Financial Year begins on July 01. - Financial Week begins from Monday, which means if July 01 falls on any other days, then we have to take the Monday of that week as the beginning of the financial week. e.g. If July 01 falls on Wednesday, then the beginning of week is June 29 &amp;lt;&amp;lt;So you have a fiscal calender based on weeks. This is one of the 150+  options in the GAAP; I am not user with your narrative if you will have fiscal weeks that are not 7 days (I have seen 4 and 12 days) to align the calendar and fiscal years.  I have modified the ISO-8601 week-within-year format to use 'F' as a marker for Fiscal weeks, as opposed to the usual 'W' for calendar weeks. Thus '2012F01-1' is the first fiscal week of 2012, and a Monday. You get the parts with substrings in computed columns, VIEWs and queries. Unfortunately, you did not define a fiscal month. In some financial calendars a month is always 30 days and a year is always 360 days with inter-calendaral days to make up the differences.</description><pubDate>Mon, 03 Sep 2012 20:36:36 GMT</pubDate><dc:creator>CELKO</dc:creator></item><item><title>RE: Fiscal Dates</title><link>http://www.sqlservercentral.com/Forums/Topic1353313-392-1.aspx</link><description>[quote][b]rka (9/2/2012)[/b][hr]DateKey has to be in the format YYYYMMDD[/quote]In SQL Server, that's a pretty insane requirement because that would make a character based date.  Since you're using SQL Server 2008, you should either use DATETIME or DATE datatypes for such a thing.I strongly recommmend you talk to the people that designed the table and suggest that they should probably change it.As for actually building the table... what have you tried that's not working?</description><pubDate>Mon, 03 Sep 2012 00:09:18 GMT</pubDate><dc:creator>Jeff Moden</dc:creator></item><item><title>Fiscal Dates</title><link>http://www.sqlservercentral.com/Forums/Topic1353313-392-1.aspx</link><description>My company wants to create a Financial Calendar Table which contains only the Fiscal Dates. The requirements is ti populate it with the following columns:- DateKey- Fiscal_Year- Fiscal_Month- Fiscal_Week- Fiscal Week_Start_Date- Fiscal_Week_End_DateThe rules for these columns are:- DateKey has to be in the format YYYYMMDD- Weeks begin from Monday - Sunday- Financial Year begins on 01/Jul- Financial Week begins from Monday , which means if 01/Jul falls on any other days, then we have to take the Monday of that week as the beginning of the financial week. e.g. If 01/Jul falls on Wednesday, then the beginning of week is 29/06Can someone help me with this script?</description><pubDate>Sun, 02 Sep 2012 20:54:43 GMT</pubDate><dc:creator>rka</dc:creator></item></channel></rss>