You are here: Re: Search Between Times « MsSQL Server « IT news, forums, messages
Re: Search Between Times

Posted by --CELKO-- on 04/22/06 18:10

>> I have some monthly data which is being encoded as Varchar...Say for the month of January 2005 it would look like '200501'. For each of my month I have a columns which gives me datetime and volume of the job. <<

Wrong on two levels. Temporal data needs temporal data types. And if
you know the string is fixed length, why make it VARCHAR(n)? Do you
really want bad data? Did you write a proper CHECK() constaint to
prevent things like '200613'? I would bet not.

The right way is to put the range pairs into a Reporting Ranges table.

CREATE TABLE ReportRanges
(start_date DATETIME NOT NULL PRIMARY KEY,
end_date DATETIME NOT NULL,
CHECK (start_date, end_date));

INSERT INTO ReportRanges
VALUES ('2005-01-01 02:00:00.000', '2005-01-31 06:00:00.000);
etc.

Use a spreadsheet to build the data, then use a simple join. 36525
rows will cover ten years of reporting.

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация