SQL DataType - 如何存储一年? [英] SQL DataType - How to store a year?

查看:15
本文介绍了SQL DataType - 如何存储一年?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在数据库中插入年份(例如:1988、1990 等).当我使用日期或日期时间数据类型,它显示错误.我应该使用哪种数据类型.

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆