以自定义格式保存日期 [英] save date in custom format

查看:75
本文介绍了以自定义格式保存日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨 我想以自定义格式在sql 2005中保存日期
就像2011年8月第3周
像这样的事情我需要一些帮助

解决方案

格式化不是SQL Server中日期数据类型的一部分.

您可以按照以下方式进行选择:
1)使用varchar(20),存储的proc和视图将日期格式化并保存为文本
2)在客户端格式化日期.

2号是更好的解决方案,因为您仍然可以使用SQL Server获得排序,数据大小等优势.

您可以在日期格式此处查看MSDN文档. [ 解决方案

Formatting is not part of the date data type in SQL server.

Your options are along the lines of the following:
1) Use varchar(20), stored procs and views to format and persist the date as text
2) Format the date on the client.

Number 2 is the much better solution as you still get the benefit of sorting, data size etc. with SQL server.

You can view the MSDN docs on date formatting
here.[^]

Cheers.


这篇关于以自定义格式保存日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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