How do I create a table with one column having year e.g. 2019, 2018 as the only data type?
Asked
Active
Viewed 57 times
-3
-
https://stackoverflow.com/q/696506/6877477 – Anton Kahwaji Apr 08 '19 at 00:51
3 Answers
1
You can store a year either as an integer (or smallint, if your database supports it), decimal(4, 0)
, or as a char(4)
.
You would use a numeric representation if you planned to do arithmetic on the years -- say adding 3 years or taking the difference. You would use a string representation if the value were only for show.

Gordon Linoff
- 1,242,037
- 58
- 646
- 786
0
I would use type DATE because you may want to use functions or expressions that use data with type DATE, perhaps in a different table.

Marichyasana
- 2,966
- 1
- 19
- 20