SQL DataType - 如何存储一年? [英] SQL DataType - How to store a year?
本文介绍了SQL DataType - 如何存储一年?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要在数据库中插入一年(例如:1988年,1990年等)。当我使用Date或Datetime
数据类型时,它显示错误。我应该使用哪种数据类型。
I need to insert a year(eg:1988 ,1990 etc) in a database. When I used Date or Datetime data type, it is showing errors. Which datatype should I use.
推荐答案
如果你需要在数据库中存储一年,你可能要使用一个Integer数据类型设置为仅存储年份)或DateTime数据类型(这将涉及存储基本上是1/1/1990 00:00:00格式的日期)。
If you need to store a year in the database, you would either want to use an Integer datatype (if you are dead set on only storing the year) or a DateTime datatype (which would involve storing a date that basically is 1/1/1990 00:00:00 in format).
这篇关于SQL DataType - 如何存储一年?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文