For example, the following would use only 2 bytes, but support only a 2
digit year:
period_month tinyint,
period_year tinyint,
The following combination would use 3 bytes and support a 4 digit year:
period_month tinyint,
period_year smallint,
For comparison, smalldatetime would be 4 bytes and datetime would be 8
bytes.
"Terri" <te...@cybernets.com> wrote in message
news:ddvkka$fep$1...@reader2.nmix.net...
"Terri" <te...@cybernets.com> wrote in message
news:ddvkka$fep$1...@reader2.nmix.net...
March 2005 = 200503
This makes the use of an index on the single column searchable and
efficient. It also means you can sort by this as well.
--
Andrew J. Kelly SQL MVP
"Terri" <te...@cybernets.com> wrote in message
news:ddvkka$fep$1...@reader2.nmix.net...
"Andrew J. Kelly" <sqlmvpn...@shadhawk.com> wrote in message
news:eNFxgV0o...@TK2MSFTNGP15.phx.gbl...
--
Andrew J. Kelly SQL MVP
"Raymond D'Anjou" <rda...@savantsoftNOSPAM.net> wrote in message
news:OQbX080...@TK2MSFTNGP14.phx.gbl...
"Andrew J. Kelly" <sqlmvpn...@shadhawk.com> wrote in message
news:eNFxgV0o...@TK2MSFTNGP15.phx.gbl...
"Andrew J. Kelly" <sqlmvpn...@shadhawk.com> wrote in message
news:u0%23NCb1o...@TK2MSFTNGP09.phx.gbl...
ML
You can put the two columns in the table or have them in a calendar
table depending on how you will use these monthly ranges. A simple
BETWEEN preidcate will do most of your work and allow you to use
indexes.
Never store them as CHAR(n) or numerics -- you will waste too much time
converting them to temporal data types. The constraints will be messy
and DRI will be complex.
As an aside, I am getting soft on the MySQL convention of zeroes for
durations -- '2005-01-00' is all of January and '2005-00-00' means all
of 2005. Unfortunately, we cannot carry this down to hours, minutes
and seconds.
"--CELKO--" <jcel...@earthlink.net> wrote in message
news:1124314488.0...@o13g2000cwo.googlegroups.com...
Are they serious?
Does '0000-00-00' stand for 'all eternity'?
ML
--
Andrew J. Kelly SQL MVP
"Raymond D'Anjou" <rda...@savantsoftNOSPAM.net> wrote in message
news:OV6BLr1o...@TK2MSFTNGP14.phx.gbl...
If you need to do calculations (add 1 month, substract 5 years) then I'd
probably choose the date type anyway because SQL Server has them
implemented already. You could use them with integer columns also but
then you need a conversion to date and back.
Kind regards
robert