数据类型存储年限? [英] Data type to store years?

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

问题描述

我应该创建一个用于将年份存储为整数字段或char(4)字段的字段吗?
非常感谢!

Should I create a field for storing years as an integer field or a char(4) field?
Thank you so much!

推荐答案

我认为,如果您需要对年份进行任何类型的计算/排序,则整数可能会有用.
但是最终,这可能取决于您将来打算在date字段上执行哪种操作.
I would think an integer may be useful if you need to perform any sort of calculations / sorting on year.

But finally it could depend on what kind of operations you might intend to perform on the date field in the future.


对于这些选项,整数要好得多.但是,如果要进行基于日期的计算,为什么不使用date.例如,仅使用一年的第一天作为日期和月份.有了date,您就不必进行从int到date的转换.
For those options integer is far better. But if you want to do date based calculations, why not use date. Just use for example the first day of year as date and month. With date, you wouldn''t have to do conversions from int to date etc.


这篇关于数据类型存储年限?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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