在sql server中显示年份的数据类型 [英] data type for showing year in sql server

查看:428
本文介绍了在sql server中显示年份的数据类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好朋友
我想将年份存储为2008-2009.在SQL Server中哪种数据类型更好.


谢谢

hello friends
i want to store year as 2008-2009. which datatype is better in sql server.


Thank you

推荐答案

存储值的唯一方法,必须使用varchar,nvarchar(string)数据类型
the only way to store the value, you have to use varchar,nvarchar (string) data type


老实说,我只需要存储实际日期,然后对其进行后期处理即可在我的外部代码或存储过程中获得纳税年度(或任何时期,即2008-2009年).

这样一来,您就不会丢弃在需求稍有变化时以后可能要使用的信息.空间差异不是很大,存储空间也很便宜.
To be honest I would just store the actual date, and just post process it to get the tax year (or whatever period is the year 2008-2009) either in my external code or a stored procedure.

That way, you aren''t discarding information you might later want to use if the requirements change slightly. The space difference isn''t massive, and storage is pretty cheap.


商店年份为2008-2009
如果要将其存储为与2008-2009年完全相同,则varchar(10) 应该最合适.
store year as 2008-2009
If you want to store it exactly as 2008-2009, then varchar(10) should fit best.


这篇关于在sql server中显示年份的数据类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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