Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我试图以“YYMM”/“YY-MM”格式存储我的日期作为日期类型而不进行转换,因为我只需要年份和月份。我在网上搜索的解决方案主要是通过转换,如 Cast 等。想知道是否可以从数据库表中的数据类型(如 Date(1, 1))配置它。谢谢!
我会将其存储为标准日期类型,而忽略这一天。
如果这不合适,我将有两列,每列 1 个字节,年份和月份。
你可以像这样存储年份和月份。
Declare @a Char(6) Set @a = Getdate() Select @a